def current_branch(): """Return the current branch""" decode = core.decode head = git.git_path('HEAD') try: key = os.stat(head).st_mtime if _current_branch.key == key: return _current_branch.value except OSError: pass status, data = git.rev_parse('HEAD', symbolic_full_name=True, with_status=True) if status != 0: # git init -- read .git/HEAD. We could do this unconditionally... data = _read_git_head(head) for refs_prefix in ('refs/heads/', 'refs/remotes/', 'refs/tags/'): if data.startswith(refs_prefix): value = decode(data[len(refs_prefix):]) _current_branch.key = key _current_branch.value = value return value # Detached head return data
def current_branch(): """Return the current branch""" decode = core.decode head = git.git_path('HEAD') try: key = os.stat(head).st_mtime if _current_branch.key == key: return _current_branch.value except OSError: pass data = git.rev_parse('HEAD', with_stderr=True, symbolic_full_name=True) if data.startswith('fatal:'): # git init -- read .git/HEAD. We could do this unconditionally # and avoid the subprocess call. It's probably time to start # using dulwich. data = _read_git_head(head) for refs_prefix in ('refs/heads/', 'refs/remotes/'): if data.startswith(refs_prefix): value = decode(data[len(refs_prefix):]) _current_branch.key = key _current_branch.value = value return value # Detached head return data
def current_branch(): """Return the current branch""" head = git.git_path("HEAD") try: key = core.stat(head).st_mtime if _current_branch.key == key: return _current_branch.value except OSError: pass status, data, err = git.rev_parse("HEAD", symbolic_full_name=True) if status != 0: # git init -- read .git/HEAD. We could do this unconditionally... data = _read_git_head(head) for refs_prefix in ("refs/heads/", "refs/remotes/", "refs/tags/"): if data.startswith(refs_prefix): value = data[len(refs_prefix) :] _current_branch.key = key _current_branch.value = value return value # Detached head return data
def save_archive(self): ref = git.rev_parse('HEAD')[STDOUT] shortref = ref[:7] GitArchiveDialog.save_hashed_objects(ref, shortref, self)
def save_archive(self): ref = git.rev_parse('HEAD') shortref = ref[:7] GitArchiveDialog.save(ref, shortref, self)
def save_archive(self): ref = git.rev_parse("HEAD")[STDOUT] shortref = ref[:7] GitArchiveDialog.save(ref, shortref, self)