Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-06-14 17:17:51 +0400
committerJunio C Hamano <gitster@pobox.com>2013-06-14 20:41:03 +0400
commitbac1ddd0f86bc5955c24f89e402de80d2844efb5 (patch)
tree7e279003ab07e34fb9220a43d53455dbafd8d6b2 /git-sh-setup.sh
parent6567dc05a34948b959864b12fcd59a35543273f7 (diff)
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 <gitster@pobox.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-sh-setup.sh')
-rw-r--r--git-sh-setup.sh12
1 files changed, 12 insertions, 0 deletions
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
+}