From: Philip Pokorny Date: Thu, 28 Apr 2005 07:17:58 GMT Subject: Re: PATCH[4/4]: Allow tree-id to return the ID of a tree object Message-ID: <42708E26.2090803@mindspring.com> In-Reply-To: <20050427232223.GM22956@pasky.ji.cz> Convert parent-id to similar style and function as the new commit-id and tree-id. NOTE: parent-id uses commit-id rather than cg-Xnormid directly Signed-off-by: Philip Pokorny Index: parent-id =================================================================== --- 6ad600e20c89323c1d3049f75b8ca9b0a2d72167/parent-id (mode:100755 sha1:f35877a6aa5b68d2fb4a388dcfa9b3e64262604e) +++ uncommitted/parent-id (mode:100775) @@ -1,12 +1,19 @@ #!/usr/bin/env bash # # Get ID of parent commit to a given revision or HEAD. +# NOTE: will return multiple SHA1s if ID is a commit with multiple parents +# # Copyright (c) Petr Baudis, 2005 # -# Takes ID of the current commit, defaults to HEAD. -PARENT="^parent [A-Za-z0-9]{40}$" +# Save for later error message +orig="$1" -id=$(commit-id $1) || exit 1 +# Normalize to SHA1 form and verify its a commit +id=$(commit-id "$1") +if [ ! "$id" ]; then + # commit-id already reported the error + exit 1 +fi -cat-file commit $id | egrep "$PARENT" | cut -d ' ' -f 2 +cat-file commit $id | awk '/^parent/{print $2};/^$/{exit}'