Created
October 25, 2011 21:37
-
-
Save ConradIrwin/1314394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -e | |
| # Removes whitespace errors (as configued by core.whitespace) from both the working | |
| # tree and the index. | |
| # Goes to some lengths to avoid problems that could be caused by applying two mechanically | |
| # altered patches in sequence. | |
| to_work=`tempfile` | |
| to_index=`tempfile` | |
| # take a diff from HEAD to the working tree. | |
| # full-index seems to be needed sometimes with binary files, TODO figuremeout | |
| git diff HEAD --full-index > $to_work | |
| # take a diff from HEAD to the index. | |
| git diff HEAD --cached --full-index > $to_index | |
| # recreate the working tree without whitespace errors (throws away the index) | |
| git reset HEAD --hard | |
| git apply $to_work --whitespace=fix | |
| # recreate the index without whitespace errors (preserves the working tree) | |
| git reset HEAD --mixed | |
| git apply $to_index --whitespace=fix --cached | |
| rm $to_index $to_head |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment