IndexFile.diff(None)
returns empty after init -> add -> write -> read
sequence on a new repository
#2025
Labels
Environment:
Description:
When initializing a new repository, adding a file to the index, writing the index to disk, and then explicitly reading the index back, a subsequent call to
repo.index.diff(None)
incorrectly returns an emptyDiffIndex
(an empty list). This occurs even though an externalgit status --porcelain
command correctly shows the file as added to the index (stage 'A').This suggests that the in-memory state of the
IndexFile
object is not correctly reflecting the on-disk state for thediff(None)
operation under these specific circumstances, even after an explicitrepo.index.read()
.Steps to Reproduce:
Actual Behavior:
repo.index.diff(None)
returns an emptyDiffIndex
(i.e.,[]
).Expected Behavior:
repo.index.diff(None)
should return aDiffIndex
containing oneDiff
object for.gitkeep
withchange_type='A'
,new_file=True
,a_path=None
, andb_path='.gitkeep'
.Additional Context:
index.diff(None)
.index.entries
dictionary does seem to reflect the added file correctly afterindex.read()
.repo.git.status(porcelain=True)
command correctly shows the file as staged for addition (A .gitkeep
).IndexFile.diff(None)
interprets theIndexFile
's state after this sequence of operations in a new repository before the first commit. Diffing againstHEAD
(once a commit exists) or other trees might behave differently.The text was updated successfully, but these errors were encountered: