From 7219d00ffa65e87f2545aaf07eb1809d3b388f6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Guido=20G=C3=BCnther?= Date: Wed, 26 Oct 2011 21:56:49 +0200 Subject: [PATCH] GitRepository: use 'git show-ref' to check a branch's existence --- gbp/git.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gbp/git.py b/gbp/git.py index 17e2fe3..a14bc86 100644 --- a/gbp/git.py +++ b/gbp/git.py @@ -225,14 +225,14 @@ class GitRepository(object): @return: C{True} if the repository has this branch, C{False} otherwise @rtype: bool """ - options = [ '--no-color' ] if remote: - options += [ '-r' ] - - for line in self.__git_getoutput('branch', options)[0]: - if line.split(' ', 1)[1].strip() == branch: - return True - return False + ref = 'refs/remotes/%s' % branch + else: + ref = 'refs/heads/%s' % branch + failed = self.__git_getoutput('show-ref', [ ref ])[1] + if failed: + return False + return True def has_treeish(self, treeish): """ -- 2.7.4