I had been asked to recompile a VPAID ActionScript SWF with a minor change to the code, but I had a lot of stuff lingering in my build I would like to temporarily disable, by commenting out, then only commit the minor change asked by using prune, ie: git add -p file.as. There was a lot of things that had changed, and it was becoming difficult to spot the changes, with all of the commented out code everywhere.
A few Google searches later, I stumbled upon a neat solution which meets my particular needs. I can mark ranges of code, and have git commit / diff ignore them. Then I can mark things that are commented out, and/or not meant for commit, and they will not be in my way.
1 | cd /your_project_path |
Then in your code, you can mark sections of code to be skipped. So if I add this block of code below…
1 | public function get thisWillRemain():Boolean { |
A “git diff” would show me:
1 | + public function get thisWillRemain():Boolean { |
Note how the function “thisIsDevOnly()” was not displayed. It was marked as a range ignore using “//gitIgnoreBegin” and “//gitIgnoreEnd”. Lines ending with these strings will be ignored in git.
This is of course only going to apply to files matching *.as, and only works if the language allows “//“ comments. With minor modification, this should work in most any language.