From: Ramkumar Ramachandra Date: Fri, 14 Jun 2013 13:17:51 +0000 (+0530) Subject: sh-setup: add new peel_committish() helper X-Git-Tag: v1.8.4-rc0~138^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bac1ddd0f86bc5955c24f89e402de80d2844efb5;p=thirdparty%2Fgit.git sh-setup: add new peel_committish() helper The normal way to check whether a certain revision resolves to a valid commit is: $ git rev-parse --verify $REV^0 Unfortunately, this does not work when $REV is of the type :/quuxery. Write a helper to work around this limitation. Suggested-by: Junio C Hamano Signed-off-by: Ramkumar Ramachandra Signed-off-by: Junio C Hamano --- diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 2f7835941e..7a964ad2ff 100644 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -313,3 +313,15 @@ then } : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"} fi + +peel_committish () { + case "$1" in + :/*) + peeltmp=$(git rev-parse --verify "$1") && + git rev-parse --verify "${peeltmp}^0" + ;; + *) + git rev-parse --verify "${1}^0" + ;; + esac +}