Skip to content

Commit bac1ddd

Browse files
artagnongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6567dc0 commit bac1ddd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

git-sh-setup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,15 @@ then
313313
}
314314
: ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}
315315
fi
316+
317+
peel_committish () {
318+
case "$1" in
319+
:/*)
320+
peeltmp=$(git rev-parse --verify "$1") &&
321+
git rev-parse --verify "${peeltmp}^0"
322+
;;
323+
*)
324+
git rev-parse --verify "${1}^0"
325+
;;
326+
esac
327+
}

0 commit comments

Comments
 (0)