Created
April 23, 2010 11:38
-
-
Save drench/376455 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 | |
# Tweaked from http://jeetworks.org/node/68 to remove bashisms. | |
# Drop this in your libexec/git-core/ to use it as "git targz" | |
if [ -z "$1" ] | |
then | |
echo "Usage: git-targz [rev] path" | |
echo | |
echo "Creates gzipped-compressed tarball archive of the current or specified branch." | |
exit 1 | |
fi | |
if [ "$#" = "1" ] | |
then | |
path=$1 | |
rev="HEAD" | |
else | |
rev=$1 | |
path=$2 | |
fi | |
basepath=`basename $path` | |
prefix=${basepath%%.*} | |
git archive --format=tar --prefix=$prefix/ $rev | gzip >$path |
never thought to much about bash vs sh. I guess it's just habit. I've changed it for you :-) thanks for testing it.
I think that ubuntu that i use runs dash anyway...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generating the filename with "git describe" is nice. But why "/bin/bash"? The only reason I wrote this modification is because the original was unnecessarily bash-only. Yours works fine for me under /bin/sh on FreeBSD.