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
test_index_mutation compares full dereferenced and non-dereferenced paths #224
======================================================================
ERROR: test_index_mutation (git.test.test_index.TestIndex)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/yoh/deb/gits/python-git/git/test/lib/helper.py", line 112, in repo_creator
return func(self, rw_repo)
File "/home/yoh/deb/gits/python-git/git/test/test_index.py", line 482, in test_index_mutation
[os.path.abspath(os.path.join('lib', 'git', 'head.py'))] * 2, fprogress=self._fprogress_add)
File "/home/yoh/deb/gits/python-git/git/index/base.py", line 684, in add
paths, entries = self._preprocess_add_items(items)
File "/home/yoh/deb/gits/python-git/git/index/base.py", line 546, in _preprocess_add_items
paths.append(self._to_relative_path(item))
File "/home/yoh/deb/gits/python-git/git/index/base.py", line 536, in _to_relative_path
raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir))
ValueError: Absolute path '/tmp/tmpX75gjinon_bare_test_index_mutation/lib/git/head.py' is not in git repository at '/home/yoh/.tmp/tmpX75gjinon_bare_test_index_mutation'
since I have
$> ls -ld $TMPDIR
lrwxrwxrwx 1 yoh yoh 5 Nov 10 2010 /home/yoh/.tmp -> /tmp//
so may be in_to_relative_path should deref both paths before comparison?
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.
IIRC, 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_dir from the beginning. I see already a use of os.path.realpath in read_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 realpath at 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).
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 ;)
I would still state that realpath isn'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 including normpath in the index implementation, I could certainly do so.
Activity
Byron commentedon Jan 5, 2015
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.
yarikoptic commentedon Jan 5, 2015
it is coming from the use of abspath to obtain absolute path for a local file
IIRC, 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
Removed all previously added invocations of os.path.realpath as it wa…
Removed os.path.realpath invocations as they are not necessary if pat…
Byron commentedon Jan 12, 2015
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).Byron commentedon Jan 12, 2015
Videos can be found here:
yarikoptic commentedon Jan 12, 2015
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 ;)
ryneeverett commentedon Feb 22, 2015
@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.:Obviously I can work around this by normalizing my own path strings as above, but is this the expected behavior?
Byron commentedon Feb 22, 2015
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 including
normpathin the index implementation, I could certainly do so.ryneeverett commentedon Feb 22, 2015
@Byron True. I'd like to at least see it stated in the API reference that paths need to be normalized.
Improved documentation on IndexFile.add(...)