@yas @metropolis
#!/bin/sh
if [ $# -ne 1 ]
then
echo "usage: $0 treeish" 1>&2
exit 1
fi
treeish="$1"
case $(git cat-file -t "${treeish}") in
commit)
git cat-file -p "${treeish}" |
sed -n 1p |
awk '{print $2}'
;;
tree)
git rev-parse "${treeish}"
;;
esac