From de50cec19b4f7e4c5a6da5ecc5cddd7a52ac3725 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 13 Dec 2012 12:36:07 +0000 Subject: Always use `git rev-parse --verify` to resolve refs Previously some code used `git show-ref`, which is wrong -- given two refs named 'alpha/master' and 'master', `git show-ref master` will return both, sorted alphabetically. This can lead to build failures, etc. due to refs resolving to the wrong SHAs. We should also use `git rev-parse --verify` to verify SHA1s, which we previously did with `git rev-list`. Finally, `git rev-parse --verify` is more than twice as fast as `git show-ref`. --- tests.branching/ambiguous-refs.script | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests.branching') diff --git a/tests.branching/ambiguous-refs.script b/tests.branching/ambiguous-refs.script index a93c4b66..0ea8a55f 100755 --- a/tests.branching/ambiguous-refs.script +++ b/tests.branching/ambiguous-refs.script @@ -16,8 +16,10 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -## 'git show-ref master' sorts its output alphabetically, so we can't rely on -## it to resolve 'master': we might get 'alpha/master' instead. +## Guard against a bug that occurs if 'git show-ref' is used to resolve refs +## instead of 'git rev-parse --verify': show-ref returns a list of partial +## matches sorted alphabetically, so any code using it may resolve refs +## incorrectly. set -eu -- cgit v1.2.1