{"thread":{"id":"44627","subject":"[PATCH] difftool: fix dir-diff index creation when in a subdirectory","startedAt":"2016-12-05T22:26:48Z","lastAt":"2016-12-06T13:47:01Z","messageCount":2,"participants":["David Aguilar","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"306973","messageId":"20161205222600.29914-1-davvid@gmail.com","threadId":"44627","inReplyTo":null,"subject":"[PATCH] difftool: fix dir-diff index creation when in a subdirectory","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2016-12-05T22:26:00Z","receivedAt":"2016-12-05T22:26:48Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"9ec26e797781239b36ebccb87c590e5778358007 corrected how path arguments\nare handled in a subdirectory, but it introduced a regression in how\nentries outside of the subdirectory are handled by dir-diff.\n\nWhen preparing the right-side of the diff we only include the\nchanged paths in the temporary area.\n\nThe left side of the diff is constructed from a temporary\nindex that is built from the same set of changed files, but it\nwas being constructed from within the subdirectory.  This is a\nproblem because the indexed paths are toplevel-relative, and\nthus they were not getting added to the index.\n\nTeach difftool to chdir to the toplevel of the repository before\npreparing its temporary indexes.  This ensures that all of the\ntoplevel-relative paths are valid.\n\nAdjust the test cases to more thoroughly exercise this scenario.\n\nReported-by: Frank Becker <fb@mooflu.com>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\nI figured I'd send this as a proper patch.\nThe patch contents have not changed since the original in-thread\npatch, but the commit message was modified slightly.\n\n git-difftool.perl   | 4 ++++\n t/t7800-difftool.sh | 7 +++++--\n 2 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex a5790d03a..959822d5f 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -182,6 +182,10 @@ EOF\n \t\t}\n \t}\n \n+\t# Go to the root of the worktree so that the left index files\n+\t# are properly setup -- the index is toplevel-relative.\n+\tchdir($workdir);\n+\n \t# Setup temp directories\n \tmy $tmpdir = tempdir('git-difftool.XXXXX', CLEANUP => 0, TMPDIR => 1);\n \tmy $ldir = \"$tmpdir/left\";\ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nindex 70a2de461..caab4b5ca 100755\n--- a/t/t7800-difftool.sh\n+++ b/t/t7800-difftool.sh\n@@ -413,8 +413,11 @@ run_dir_diff_test 'difftool --dir-diff from subdirectory' '\n \t(\n \t\tcd sub &&\n \t\tgit difftool --dir-diff $symlinks --extcmd ls branch >output &&\n-\t\tgrep sub output &&\n-\t\tgrep file output\n+\t\t# \"sub\" must only exist in \"right\"\n+\t\t# \"file\" and \"file2\" must be listed in both \"left\" and \"right\"\n+\t\ttest \"1\" = $(grep sub output | wc -l) &&\n+\t\ttest \"2\" = $(grep file\"$\" output | wc -l) &&\n+\t\ttest \"2\" = $(grep file2 output | wc -l)\n \t)\n '\n \n-- \n2.11.0\n\n"},{"id":"307004","messageId":"alpine.DEB.2.20.1612061446230.117539@virtualbox","threadId":"44627","inReplyTo":"20161205222600.29914-1-davvid@gmail.com","subject":"Re: [PATCH] difftool: fix dir-diff index creation when in a subdirectory","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-12-06T13:46:48Z","receivedAt":"2016-12-06T13:47:01Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi David,\n\nOn Mon, 5 Dec 2016, David Aguilar wrote:\n\n> 9ec26e797781239b36ebccb87c590e5778358007 corrected how path arguments\n\nHow about using the \"whatis\" instead, i.e. \"9ec26e7977 (difftool: fix\nargument handling in subdirs, 2016-07-18)\"?\n\nCiao,\nDscho\n"}]}