diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-11-27 09:37:32 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-11-27 18:02:40 +0100 |
commit | ec2b74c97a9253d4cf4a311bd5f1f7145187ef06 (patch) | |
tree | 62b55a1fdba8b5eb182a63b203f920a55d3695f3 | |
parent | 3591792965ae3c3129ad975ab8f8ff0c6ff52aef (diff) | |
download | git-buildpackage-ec2b74c97a9253d4cf4a311bd5f1f7145187ef06.tar.gz git-buildpackage-ec2b74c97a9253d4cf4a311bd5f1f7145187ef06.tar.bz2 git-buildpackage-ec2b74c97a9253d4cf4a311bd5f1f7145187ef06.zip |
GitRepository/strip_sha1: fix length checking
Accept longer sha1 than what was asked for. The length option given to
git is merely a "wish to get a sha1 of this length". Git may also return
longer sha1 if truncating to given length would give
ambiguous/non-unique sha1.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | gbp/git/repository.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 5c13e40b..32e9f1ef 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -729,6 +729,8 @@ class GitRepository(object): GitRepositoryError: '58ef37d' is not a valid sha1 of length 10 >>> GitRepository.strip_sha1('58ef37d', 7) '58ef37d' + >>> GitRepository.strip_sha1('123456789', 7) + '123456789' >>> GitRepository.strip_sha1('foobar') Traceback (most recent call last): ... @@ -737,7 +739,7 @@ class GitRepository(object): s = sha1.strip() l = length if length else 40 - if len(s) != l: + if len(s) < l: raise GitRepositoryError("'%s' is not a valid sha1%s" % (s, " of length %d" % l if length else "")) return s |