You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using pygit2-0.28.1, I have an issue when using for example repo.branches.with_commit() and one of the branches is in the packed-refs file.
Reproduce with tests/submodulerepo.tar:
subrepo=pygit2.Repository(r"path\pygit2\test\data\submodulerepo")
# SHA1 for refs/remotes/origin/master from submodulerepo/.git/packed-refsbranches=subrepo.branches.with_commit('215fc695515c4093e2beffb21225ce6e1b3d55bc')
list(branches.remote) # This raises ValueError
You'll get:
File "<input>", line 1, in <module>
File "path\lib\site-packages\pygit2\repository.py", line 1181, in __iter__
if self._commit is None or self.get(branch_name) is not None:
File "path\lib\site-packages\pygit2\repository.py", line 1175, in get
return self[key]
File "path\lib\site-packages\pygit2\repository.py", line 1168, in __getitem__
if branch is None or not self._valid(branch):
File "path\lib\site-packages\pygit2\repository.py", line 1197, in _valid
self._repository.descendant_of(branch.target, self._commit))
ValueError: refs/remotes/origin/master
I'm not 100% sure that it's related to packed-ref, but I tried reproducing when the ref actually exists as a file and didn't get the same issue.
In my ignorance I came up with a workaround,
# pygit2/repository.py :: L1190def_valid(self, branch):
try:
target=self._repository.expand_id(branch.target)
exceptValueError:
target=self._repository.expand_id(self._repository.lookup_reference(branch.target).target)
return (self._commitisNoneortarget==self._commitor# target was branch.targetself._repository.descendant_of(target, self._commit)) # target was branch.target
The text was updated successfully, but these errors were encountered:
Using pygit2-0.28.1, I have an issue when using for example
repo.branches.with_commit()
and one of the branches is in the packed-refs file.Reproduce with
tests/submodulerepo.tar
:You'll get:
I'm not 100% sure that it's related to packed-ref, but I tried reproducing when the ref actually exists as a file and didn't get the same issue.
In my ignorance I came up with a workaround,
The text was updated successfully, but these errors were encountered: