summaryrefslogtreecommitdiffstats
path: root/git-tarball
blob: c7b49b55c121831234901173841c236ac71258d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

COMPRESSION="gz"

if [ $# -ne 1 ]; then
    echo "usage: git-tarball <tag|commit>" >&2
    exit 1
fi

name="$(basename $(readlink -f .))"
tag="$1"

echo "Creating archive for '$name' => '$name-$tag.tar.$COMPRESSION'"

if [ "$COMPRESSION" = "gz" ]; then
    git archive --prefix="$name-$tag/" "$tag" | gzip --best > $name-$tag.tar.gz
elif [ "$COMPRESSION" = "bz2" ]; then
    git archive --prefix="$name-$tag/" "$tag" | bzip2 --best > $name-$tag.tar.bz2
fi