usage() {
cat <<EOF
-Usage: cat-git-tree ID
+Usage: cat-git-tree [--git-dir DIR] ID
EOF
}
esac
}
-if test $# -ne 1
-then
- usage 1>&2
- exit 1
-fi
+case $# in
+ 1) ;;
+ 3)
+ if test "$1" != --git-dir; then
+ usage 1>&2
+ exit 1
+ fi
+ export GIT_DIR="$2"
+ shift 2
+ ;;
+ *)
+ usage 1>&2
+ exit 1
+ ;;
+esac
top="$1"
type=$(git cat-file -t "$top") || exit $?