#!/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.
#
# NOTE: Will return multiple SHA1s if ID is a commit with multiple parents.

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

git-cat-file commit $id | awk '/^parent/{print $2};/^$/{exit}'
