GNOME Bugzilla – Bug 564672
Don't use git-rev-parse to check for branch existance
Last modified: 2009-04-24 14:14:47 UTC
def branch_exist(self, branch): if not branch: return False try: get_output(['git', 'rev-parse', branch], cwd = self.srcdir) return True except: return False def branchname(self): for b in [self.tag, 'origin/' + str(self.branch), 'origin/svn/' + str(self.branch), self.branch, 'origin/master', 'origin/trunk', 'master', 'trunk']: if self.branch_exist(b): return b raise GitUnknownBranchNameError() branchname = property(branchname) git-rev-parse does guessing on the argument to determine what it is. The combination of that with the "try everything" approach can produce very strange and confusing results. I'd suggest using git-show-rev --quiet --verify to check for the existence of branch. git-show-rev --quiet --verify refs/remotes/origin/<branchname> git-show-rev --quiet --verify refs/heads/master
Err, that's "git show-ref", not git-show-rev.
I do not feel confortable doing this myself, apart: - get_output(['git', 'rev-parse', branch], cwd = self.srcdir) + get_output(['git', 'show-rev', '--quiet', '--verify', branch], cwd = self.srcdir) What was the reasoning for checking origin/master and master? what about git-svn support provided by origin/svn/ + self.branch? Could someone with more git confidence write a patch? (marc-andre and john, you are somehow targetted here :) )
I went ahead, but didn't check git-svn and git-cvs were still ok. commit bb0119d28d8d4823a493f43f165ee2575366bf73 Author: Frederic Peters <fpeters@0d.be> Date: Fri Apr 24 16:08:46 2009 +0200 improve git support in many ways Changes to a simpler support of branches; switch from git fetch/git rebase to git pull --rebase, only stash when there is a diff, and pop afterwards, and no longer use git rev-parse to check for branch existance. (GNOME #532673, #549704, #552476 and #564672)