GOTCHA: Sometimes len(pygit2.Repository().index) > 0 !
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 408
- Avg merge
- 2d 57m
- Merged PRs (30d)
- 7
Description
Python 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygit2
>>> len(pygit2.Repository().index)
2
>>> for item in pygit2.Repository().index: print(item)
...
<path=aaaa id=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 mode=33188>
<path=bbbb id=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 mode=33188>
>>> pygit2.__version__
'1.10.1'
This really surprised me, and I spent over 2 hours wondering why my code did not work before I thought maybe there's a bug.
With hindsight, I think it will be easy to reproduce. Ask me if you want help with this.
I will use index.clear() as a work-around.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Python 3.10.6 example with pygit2 1.10.1, especially the call to pygit2.Repository().index and its entries. Trace why a new repository index contains aaaa and bbbb, then establish the intended empty-index behavior and verify the correction with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100