difftool: fix dir-diff index creation when in a subdirectory
PATCH v2 1/1 difftool: fix dir-diff index creation when in a subdirectory
9ec26e7977 (difftool: fix argument handling in subdirs, 2016-07-18) corrected how path arguments are handled in a subdirectory, but it introduced a regression in how entries outside of the subdirectory are handled by dir-diff.
When preparing the right-side of the diff we only include the changed paths in the temporary area.
The left side of the diff is constructed from a temporary index that is built from the same set of changed files, but it was being constructed from within the subdirectory. This is a problem because the indexed paths are toplevel-relative, and thus they were not getting added to the index.
Teach difftool to chdir to the toplevel of the repository before preparing its temporary indexes. This ensures that all of the toplevel-relative paths are valid.
Add test cases to more thoroughly exercise this scenario.
---
Changes since v1:
- Improved commit message thanks to Johannes Schindelin ("git whatis" was used to describe the referenced commit)
- Add more tests for edge cases that are properly handled but were not being tested.
git-difftool.perl | 4 ++++ t/t7800-difftool.sh | 44 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 3 deletions(-)
git-difftool.perl +4 -0
@@ -182,6 +182,10 @@ EOF } } + # Go to the root of the worktree so that the left index files + # are properly setup -- the index is toplevel-relative. + chdir($workdir); + # Setup temp directories my $tmpdir = tempdir('git-difftool.XXXXX', CLEANUP => 0, TMPDIR => 1); my $ldir = "$tmpdir/left";
t/t7800-difftool.sh +41 -3
59 lines not on this page · raw message
Signature · 1 line
2.11.0.1.g7697df0
Thanks; queued and pushed out together with the follow-up series.