aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/git/repository.py
diff options
context:
space:
mode:
Diffstat (limited to 'gbp/git/repository.py')
-rw-r--r--gbp/git/repository.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 63957789..48d00533 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -1545,7 +1545,12 @@ class GitRepository(object):
raise
else: # empty repo
cur = None
- branch = 'master'
+ out, _, ret = self._git_inout('symbolic-ref', ['HEAD'],
+ capture_stderr=True)
+ if ret:
+ raise GitRepositoryError("Currently not on a branch")
+ ref = out.decode().split('\n')[0]
+ branch = ref[len('/refs/heads'):]
# Build list of parents:
parents = []