Skip to content

Commit 031271e

Browse files
committed
git.repo.base: substituted all usages of the active_branch property with self.head.* in order to more safely get the current commit. active_branch would only work on non-detached heads
1 parent b4b50e7 commit 031271e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

git/repo/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def commit(self, rev=None):
368368
:param rev: revision specifier, see git-rev-parse for viable options.
369369
:return: ``git.Commit``"""
370370
if rev is None:
371-
return self.active_branch.commit
371+
return self.head.commit
372372
else:
373373
return self.rev_parse(str(rev)+"^0")
374374

@@ -391,7 +391,7 @@ def tree(self, rev=None):
391391
it cannot know about its path relative to the repository root and subsequent
392392
operations might have unexpected results."""
393393
if rev is None:
394-
return self.active_branch.commit.tree
394+
return self.head.commit.tree
395395
else:
396396
return self.rev_parse(str(rev)+"^{tree}")
397397

@@ -415,7 +415,7 @@ def iter_commits(self, rev=None, paths='', **kwargs):
415415
416416
:return ``git.Commit[]``"""
417417
if rev is None:
418-
rev = self.active_branch
418+
rev = self.head.commit
419419

420420
return Commit.iter_items(self, rev, paths, **kwargs)
421421

@@ -739,7 +739,7 @@ def archive(self, ostream, treeish=None, prefix=None, **kwargs):
739739
:raise GitCommandError: in case something went wrong
740740
:return: self"""
741741
if treeish is None:
742-
treeish = self.active_branch
742+
treeish = self.head.commit
743743
if prefix and 'prefix' not in kwargs:
744744
kwargs['prefix'] = prefix
745745
kwargs['output_stream'] = ostream

0 commit comments

Comments
 (0)