Created
August 6, 2013 09:46
-
-
Save elleryq/6163200 to your computer and use it in GitHub Desktop.
Get before/after files from specified commit-id.
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 | |
| if [ -z $1 ]; then | |
| echo "Need commitid." | |
| exit -1 | |
| fi | |
| FILES=`git diff-tree --no-commit-id --name-only -r $1` | |
| OUTPUT='/tmp/git-diff' | |
| mkdir -p $OUTPUT | |
| mkdir -p $OUTPUT/before | |
| mkdir -p $OUTPUT/after | |
| for FILE in $FILES; do | |
| NEW_FILENAME=`basename $FILE` | |
| git show $1~1:$FILE > $OUTPUT/before/$NEW_FILENAME | |
| git show $1:$FILE > $OUTPUT/after/$NEW_FILENAME | |
| done | |
| 7za a -r ~/tmp/$1.7z $OUTPUT/* | |
| rm -rf $OUTPUT | |
| echo "done". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment