blob: 4becad9d1deb3833d0464ef87df07399c258fb9e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/bin/sh
set -e
git rev-parse || exit 1
errx() {
printf '%s\n' "$*" >&2
exit 1
}
usage() {
errx 'usage: git package [-f format] tree-ish [path...]'
}
format="$(git config --get package.format)"
: "${format:=tar.gz}"
while getopts f: opt; do
case $opt in
f) format=$OPTARG;;
?) usage;;
esac
done
shift $((OPTIND - 1))
test $# -ge 1 || usage
git archive -l | grep -Fqx "$format" || err "fatal: unknown format"
name="$(basename "$(git rev-parse --show-toplevel)")"
treeish="$1"
exec git archive --prefix="$name-$treeish/" -o "$name-$treeish.$format" -- "$@"
|