{"thread":{"id":"42344","subject":"[PATCH 1/2] difftool: initialize variables for readability","startedAt":"2016-05-16T18:05:36Z","lastAt":"2016-05-16T21:53:45Z","messageCount":3,"participants":["David Aguilar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"286688","messageId":"20160516180537.22212-1-davvid@gmail.com","threadId":"42344","inReplyTo":null,"subject":"[PATCH 1/2] difftool: initialize variables for readability","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2016-05-16T18:05:36Z","receivedAt":"2016-05-16T18:05:36Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"The code always goes into one of the two conditional blocks but make it\nclear that not doing so is an error condition by setting $ok to 0.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-difftool.perl | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex 488d14b..8cf0040 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -273,7 +273,7 @@ EOF\n \t# temporary file to both the left and right directories to show the\n \t# change in the recorded SHA1 for the submodule.\n \tfor my $path (keys %submodule) {\n-\t\tmy $ok;\n+\t\tmy $ok = 0;\n \t\tif (defined($submodule{$path}{left})) {\n \t\t\t$ok = write_to_file(\"$ldir/$path\",\n \t\t\t\t\"Subproject commit $submodule{$path}{left}\");\n@@ -289,7 +289,7 @@ EOF\n \t# shows only the link itself, not the contents of the link target.\n \t# This loop replicates that behavior.\n \tfor my $path (keys %symlink) {\n-\t\tmy $ok;\n+\t\tmy $ok = 0;\n \t\tif (defined($symlink{$path}{left})) {\n \t\t\t$ok = write_to_file(\"$ldir/$path\",\n \t\t\t\t\t$symlink{$path}{left});\n-- \n2.8.2.404.gdfc6a507\n"},{"id":"286689","messageId":"20160516180537.22212-2-davvid@gmail.com","threadId":"42344","inReplyTo":"20160516180537.22212-1-davvid@gmail.com","subject":"[PATCH 2/2] difftool: handle unmerged files in dir-diff mode","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2016-05-16T18:05:37Z","receivedAt":"2016-05-16T18:05:37Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"When files are unmerged they can show up as both unmerged and\nmodified in the output of `git diff --raw`.  This causes\ndifftool's dir-diff to create filesystem entries for the same\npath twice, which fails when it encounters a duplicate path.\n\nEnsure that each worktree path is only processed once.\nAdd a test to demonstrate the breakage.\n\nReported-by: Jan Smets <jan@smets.cx>\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-difftool.perl   |  5 +++++\n t/t7800-difftool.sh | 23 +++++++++++++++++++++++\n 2 files changed, 28 insertions(+)\n\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex 8cf0040..ebd13ba 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -138,6 +138,7 @@ sub setup_dir_diff\n \tmy %submodule;\n \tmy %symlink;\n \tmy @working_tree = ();\n+\tmy %working_tree_dups = ();\n \tmy @rawdiff = split('\\0', $diffrtn);\n \n \tmy $i = 0;\n@@ -188,6 +189,10 @@ EOF\n \t\t}\n \n \t\tif ($rmode ne $null_mode) {\n+\t\t\t# Avoid duplicate working_tree entries\n+\t\t\tif ($working_tree_dups{$dst_path}++) {\n+\t\t\t\tnext;\n+\t\t\t}\n \t\t\tmy ($use, $wt_sha1) = use_wt_file($repo, $workdir,\n \t\t\t\t\t\t\t  $dst_path, $rsha1);\n \t\t\tif ($use) {\ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nindex ff7a9e9..7ce4cd7 100755\n--- a/t/t7800-difftool.sh\n+++ b/t/t7800-difftool.sh\n@@ -419,6 +419,29 @@ run_dir_diff_test 'difftool --dir-diff when worktree file is missing' '\n \tgrep file2 output\n '\n \n+run_dir_diff_test 'difftool --dir-diff with unmerged files' '\n+\ttest_when_finished git reset --hard &&\n+\ttest_config difftool.echo.cmd \"echo ok\" &&\n+\tgit checkout -B conflict-a &&\n+\tgit checkout -B conflict-b &&\n+\tgit checkout conflict-a &&\n+\techo a >>file &&\n+\tgit add file &&\n+\tgit commit -m conflict-a &&\n+\tgit checkout conflict-b &&\n+\techo b >>file &&\n+\tgit add file &&\n+\tgit commit -m conflict-b &&\n+\tgit checkout master &&\n+\tgit merge conflict-a &&\n+\ttest_must_fail git merge conflict-b &&\n+\tcat >expect <<-EOF &&\n+\t\tok\n+\tEOF\n+\tgit difftool --dir-diff $symlinks -t echo >actual &&\n+\ttest_cmp expect actual\n+'\n+\n write_script .git/CHECK_SYMLINKS <<\\EOF\n for f in file file2 sub/sub\n do\n-- \n2.8.2.404.gdfc6a507\n"},{"id":"286724","messageId":"xmqqd1ol1xg6.fsf@gitster.mtv.corp.google.com","threadId":"42344","inReplyTo":"20160516180537.22212-2-davvid@gmail.com","subject":"Re: [PATCH 2/2] difftool: handle unmerged files in dir-diff mode","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-16T21:53:45Z","receivedAt":"2016-05-16T21:53:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks, will queue.\n"}]}