blob: 2bdfce48dd57a7c3d8da6093d05c55fcc3f91b8e (
plain) (
tree)
|
|
#!/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)" || true
: "${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" -- "$@"
|