Skip to content

Commit

Permalink
branches.with_commit supports symbolic refs
Browse files Browse the repository at this point in the history
Fixes #910
  • Loading branch information
jdavid committed May 25, 2019
1 parent 07b19dd commit 28e2e1a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pygit2/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from _pygit2 import GIT_CHECKOUT_SAFE, GIT_CHECKOUT_RECREATE_MISSING, GIT_DIFF_NORMAL
from _pygit2 import GIT_FILEMODE_LINK
from _pygit2 import GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE, GIT_BRANCH_ALL
from _pygit2 import GIT_REF_SYMBOLIC
from _pygit2 import Reference, Tree, Commit, Blob

from .config import Config
Expand Down Expand Up @@ -1188,8 +1189,14 @@ def delete(self, name):
self[name].delete()

def _valid(self, branch):
return (self._commit is None or branch.target == self._commit or
self._repository.descendant_of(branch.target, self._commit))
if branch.type == GIT_REF_SYMBOLIC:
branch = branch.resolve()

return (
self._commit is None
or branch.target == self._commit
or self._repository.descendant_of(branch.target, self._commit)
)

def with_commit(self, commit):
assert self._commit is None
Expand Down

0 comments on commit 28e2e1a

Please sign in to comment.