#!/usr/bin/env bash
#
# Get ID of parent commit to a given revision or HEAD.
# Copyright (c) Petr Baudis, 2005
#
# Takes ID of the current commit, defaults to HEAD.

PARENT="^parent [A-Za-z0-9]{40}$"

id=$(commit-id $1) || exit 1

cat-file commit $id | egrep "$PARENT" | cut -d ' ' -f 2
