aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/git
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-11-12 17:48:03 +0100
committerGuido Günther <agx@sigxcpu.org>2017-11-12 17:48:03 +0100
commitff03bec0707b4566a4f0e0228a942c1ceedab662 (patch)
treef1fdf433566594084573654cf6481fe00c025926 /gbp/git
parentb775e36d5589b1ab0ce429c76ad4b68c5b476a95 (diff)
GitRepository: require an exact ref path when looking for branches
Otherwise we might match on refs/heads/refs/heads/foo instead of refs/heads/foo when looking for branch named 'foo' Closes: #813298
Diffstat (limited to 'gbp/git')
-rw-r--r--gbp/git/repository.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index aeaa5a36..a7524a4d 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -402,12 +402,12 @@ class GitRepository(object):
@return: C{True} if the repository has this branch, C{False} otherwise
@rtype: C{bool}
"""
- if remote:
- ref = 'refs/remotes/%s' % branch
- else:
- ref = 'refs/heads/%s' % branch
+ args = GitArgs('--verify')
+
+ branch_pattern = 'refs/remotes/%s' if remote else 'refs/heads/%s'
+ args.add(branch_pattern % branch)
try:
- self._git_command('show-ref', [ref])
+ self._git_command('show-ref', args.args)
except GitRepositoryError:
return False
return True