Skip to content

Instantly share code, notes, and snippets.

@Loffe
Created December 28, 2009 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Loffe/264630 to your computer and use it in GitHub Desktop.
Save Loffe/264630 to your computer and use it in GitHub Desktop.
#!/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