Browse Source

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>
maint
Ramkumar Ramachandra 12 years ago committed by Junio C Hamano
parent
commit
bac1ddd0f8
  1. 12
      git-sh-setup.sh

12
git-sh-setup.sh

@ -313,3 +313,15 @@ then @@ -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…
Cancel
Save