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
{{ message }}
Repository navigation
Repository.diff fails when treeish is "empty" #432
So git is assuming that every other implementation is going to support the fake empty tree and it doesn't bother writing the actual tree it wants to use to disc? That is quite worrying.
This behaviour has nothing to do with git-core's special handling of the empty tree in some situations, or really with the Git system at all, it's purely an unfortunate decision in Python to consider that an object with a sequence interface is falsy just because the length of that aspect is zero.
I disagree with the solution. It is the code in Repository.diff which is wrong and should be spelled
differently. It should be explicit.
Regarding the if len == 0 then falsy debate, I have not yet stop to think about it, so I don't
have an opinion yet, anyway, that's to be discussed in PR #433
Activity
workaround for libgit2/pygit2#432
carlosmn commentedon Oct 6, 2014
So git is assuming that every other implementation is going to support the fake empty tree and it doesn't bother writing the actual tree it wants to use to disc? That is quite worrying.
No object should ever be False
carlosmn commentedon Oct 6, 2014
This behaviour has nothing to do with git-core's special handling of the empty tree in some situations, or really with the Git system at all, it's purely an unfortunate decision in Python to consider that an object with a sequence interface is falsy just because the length of that aspect is zero.
No object should ever be False
No object should ever be False
No object should ever be False
jdavid commentedon Oct 7, 2014
I disagree with the solution. It is the code in
Repository.diffwhich is wrong and should be spelleddifferently. It should be explicit.
Regarding the if len == 0 then falsy debate, I have not yet stop to think about it, so I don't
have an opinion yet, anyway, that's to be discussed in PR #433
jdavid commentedon Oct 7, 2014
There is by the way at least one more bug, when the input is a reference.
carlosmn commentedon Oct 7, 2014
There are more issues with this method, yes. I have a refactored version which should clear away the issue as well.
carlosmn commentedon Oct 7, 2014
PR #434 would also fix this, as well as working for references.
Fix Repository.diff for references an empty trees
jdavid commentedon Oct 7, 2014
@carlosmn ouch, just pushed my version, feel free to improve it
@Inkane please check if it works for you
Inkane commentedon Oct 7, 2014
@jdavid : Your change does indeed fix my issue.