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>
This commit is contained in:
parent
6567dc05a3
commit
bac1ddd0f8
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user