pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

GOTCHA: Sometimes len(pygit2.Repository().index) > 0 !

Open jfine2358 opened this issue 3 years ago • 0 comments

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.

jfine2358 avatar Oct 27 '22 12:10 jfine2358