If you have an empty repository (git init in an empty folder), then add files through GitPython, the repository isn't registered as "dirty" and diffs come back empty. For example:
The index.entries property shows the newly added file, but there doesn't seem to be a way to turn it into "this file has been added, but not committed".
Actually, diff() works just fine. If you add some files into the index, you have to append staged (or cached) parameter to make diff to show the changes.
But is_dirty() behaves inconsistently. It should indeed return False. My patch (1253036) fixes it. But I'm unable to run your nose tests and therefore I cannot update them. Hope this helps:
Even though plenty of work has been done on this already, there is no test-case yet to truly verify this works. It should be done when working on 0.3.5.
A lot of time has passed, and plenty of changes were applied to is_dirty(). Additionally, there are plenty of tests checking all aspects of it.
Therefore I believe this issue can be closed for now.
Activity
fcelda commented on Mar 21, 2012
Actually, diff() works just fine. If you add some files into the index, you have to append staged (or cached) parameter to make diff to show the changes.
But is_dirty() behaves inconsistently. It should indeed return False. My patch (1253036) fixes it. But I'm unable to run your nose tests and therefore I cannot update them. Hope this helps:
nemec commented on Mar 22, 2012
Ah, I must have missed out on the staged keyword in the docs. Thanks.
Fix issue gitpython-developers#41: repo.is_dirty() on empty repositor…
Fix issue gitpython-developers#41: repo.is_dirty() on empty repositor…
Merge pull request #193 from maxyz/fix-issue-41_master
Merge pull request #194 from maxyz/fix-issue-41_0.3
Byron commented on Nov 19, 2014
Even though plenty of work has been done on this already, there is no test-case yet to truly verify this works. It should be done when working on 0.3.5.
Byron commented on Jan 8, 2015
A lot of time has passed, and plenty of changes were applied to is_dirty(). Additionally, there are plenty of tests checking all aspects of it.
Therefore I believe this issue can be closed for now.
Merge pull request gitpython-developers#41 from nooperpudd/master
Replace use of mktemp