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`. --- morphlib/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'morphlib/git.py') diff --git a/morphlib/git.py b/morphlib/git.py index 7985b815..1c704337 100644 --- a/morphlib/git.py +++ b/morphlib/git.py @@ -256,4 +256,4 @@ def is_valid_sha1(ref): def rev_parse(runcmd, gitdir, ref): '''Find the sha1 for the given ref''' - return runcmd(['git', 'rev-parse', ref], cwd=gitdir)[0:40] + return runcmd(['git', 'rev-parse', '--verify', ref], cwd=gitdir)[0:40] -- cgit v1.2.1