GitPython
GitPython copied to clipboard
Inconsistent Tree.__contains__ / Tree.__getitem__ behaviour
The fe5289ed introduced the Tree.__contains__
behaviour change, which is inconsistent with Tree.__getitem__
behaviour. I couldn't find a proper explanation for a such change, so it looks like a bug for me:
ipdb> p tree.path
'data_dir'
ipdb> p [i.name for i in tree]
['data_sub_dir']
ipdb> p tree['data_sub_dir']
<git.Tree "43420912747f332d8bbd0859003a032a301ebbd6">
ipdb> p 'data_sub_dir' in tree
False
ipdb> p 'data_dir/data_sub_dir' in tree
True
Not sure if this could be fixed now due to compatibility reasons, but if so, could there be a better workaround than iterating over Tree._cache
?
Thanks for bringing this up! It's a bit disturbing to see the referenced commit was created by me just... 9 years ago!
To me, it also looks like a bug! The behaviour I would expect is 'data_sub_dir' in tree
to be true and the other one to be false.
any ideas how to address the cache issue ?