Repository navigation
test_index_mutation compares full dereferenced and non-dereferenced paths #224
Description
Activity
It would be worth investigating where the path-mismatch is introduced. This is exactly where it's fixed ideally.
If this is the only failing test on your system due to this issue, I would be somewhat relieved though.it is coming from the use of abspath to obtain absolute path for a local file
$> git grep -2 abspath git/test/test_index.py git/test/test_index.py- # same file git/test/test_index.py- entries = index.reset(new_commit).add( git/test/test_index.py: [os.path.abspath(os.path.join('lib', 'git', 'head.py'))] * 2, fprogress=self._fprogress_add) git/test/test_index.py- self._assert_entries(entries) git/test/test_index.py- assert entries[0].mode & 0o644 == 0o644IIRC, at some point I have looked into this issue, and there were no reliable way to obtain un-dereferenced current directory to then create "abspath" without actually dereferencing the path. Apparently IIRC it is more of a 'shell gimmick' to know that it is e.g. under ~/.tmp instead of physically being under /tmp (as OS would report, and thus abspath and getcwd). So I wondered if it might be worth dereferencing
repo.working_tree_dirfrom the beginning. I see already a use of os.path.realpath inread_gitfile...I have some other failures still but I believe they are not related to this one
All tests should work natively now even with a symbolic link as TMPDIR. My solution is to not use
realpathat all, but instead operate on paths consistently. That should save the IOPs otherwise necessary to obtain such a realpath (which as to read and follow symlinks).Videos can be found here:
OMG -- I am in a movie! ;) Quite cool of you to produce those -- I didn't know, quite a nice idea, may be the *net will hear my angry russian cursing at some point as well ;)
@Byron I'm confused by your conclusion that
os.path.realpath"wasn't required afterall" in ede325d.43e430d seems to be the only commit that doesn't throw the above
ValueErrorwhen a non-normalized absolute path is added to the index. E.g.:>>> my_path = '/home/user/./repo/file' >>> os.path.isabs(my_path) True >>> repo.index.add([my_path]) ... ValueError: Absolute path '/home/user/./repo/file' is not in git repository at '/home/user/repo' >>> my_path = os.path.realpath(my_path) >>> repo.index.add([my_path]) <success>
Obviously I can work around this by normalizing my own path strings as above, but is this the expected behavior?
I would still state that
realpathisn't required. In your case,normpathis advised and it should work. In the recording, I might have come to the conclusion that application should sanitise their paths themselves, gitpython seems sufficiently low-level to be able to expect that.
This is just my current opinion though, and if you want to make a statement towards includingnormpathin the index implementation, I could certainly do so.@Byron True. I'd like to at least see it stated in the API reference that paths need to be normalized.
- added a commit that references this issue
on Feb 23, 2015


since I have
so may be in_to_relative_path should deref both paths before comparison?