Created
December 28, 2009 11:13
-
-
Save Loffe/264630 to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
usage() | |
{ | |
echo "Usage: `basename $0` [-vh] pack_name" | |
echo " Find all modified files since current branch and master" | |
echo " diverged and put them in \$pack_name.tar.gz" | |
} | |
QUIT=0 | |
verbose=0 | |
while getopts "vh" OPTIONS ; do | |
case ${OPTIONS} in | |
h|-help) | |
usage | |
QUIT=1 | |
exit;; | |
v|-verbose) | |
verbose=1;; | |
?) | |
QUIT=1 | |
esac | |
done | |
if [ $QUIT = 1 ]; then | |
exit | |
fi | |
shift $((OPTIND-1)); OPTIND=1 | |
pack_name=$@ | |
current_branch=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
merge_base=`git merge-base $current_branch master` | |
files=`git diff --stat $merge_base | head -n -1 | cut --fields=2 -d " "` | |
if [ $verbose ]; then | |
echo "Packing files:" | |
for file in $files; do | |
echo " $file"; | |
done | |
fi | |
tar -czf $pack_name.tar.gz $files | |
echo "Wrote $pack_name.tar.gz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment