#!/usr/bin/env bash
#
# Get ID of commit associated with given id or HEAD.
# Copyright (c) Petr Baudis, 2005
#
# Takes the appropriate ID, defaults to HEAD.

. ${COGITO_LIB}cg-Xlib

id="$1"
normid=$(${COGITO_LIB}cg-Xnormid "$id") || exit 1

if [ "$(git-cat-file -t "$normid")" != "commit" ]; then
	echo "Invalid commit id: $id" >&2
	exit 1
fi

echo $normid
