{"thread":{"id":"40653","subject":"[BUG] diff --word-diff inconsistently places removed words","startedAt":"2015-10-27T01:40:12Z","lastAt":"2015-10-27T01:40:13Z","messageCount":2,"participants":["Lucian Poston"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"272285","messageId":"1445910013-13382-1-git-send-email-lucian.poston@gmail.com","threadId":"40653","inReplyTo":null,"subject":"[BUG] diff --word-diff inconsistently places removed words","fromName":"Lucian Poston","fromEmail":"lucian.poston@gmail.com","sentAt":"2015-10-27T01:40:12Z","receivedAt":"2015-10-27T01:40:12Z","isPatch":false,"sender":{"key":"lucian.poston@gmail.com","avatar":"https://avatars.githubusercontent.com/u/646121?v=4"},"body":"In the output generated by diff --word-diff, if the first word of a line was\nremoved, it may appear at the end of the previous line. For example, compare\nthe following two diffs on the same files, the first diff without --word-diff\nand the second with it.\n\n\n$ git diff\n\ndiff --git a/smallest-test b/smallest-test\nindex bc5f07a..d9116b1 100644\n--- a/smallest-test\n+++ b/smallest-test\n@@ -1,7 +1,7 @@\n \n-111 aaa\n-111 aaa\n+ aaa\n+ aaa\n \n 111 aaa\n-111 aaa\n+ aaa\n \n\n\n$ git diff --word-diff=plain\n\ndiff --git a/smallest-test b/smallest-test\nindex bc5f07a..d9116b1 100644\n--- a/smallest-test\n+++ b/smallest-test\n@@ -1,7 +1,7 @@\n\n[-111-] aaa[-111-]\n aaa\n\n111 aaa\n[-111-] aaa\n\n\nI would expect every [-111-] to be on the line where it was removed. Instead\nit appears on the previous line in the case where the previous line also has a\nremoval.\n\nIs this expected behavior?\n\nThere is also a patch in this email thread that contains a test to further\nillustrate the issue. Running the test fails with the following diff between\nthe expected result and actual result.\n\n--- expect\t2015-10-27 01:08:05.415252713 +0000\n+++ output.decrypted\t2015-10-27 01:08:05.418252766 +0000\n@@ -6,5 +6,5 @@\n 11aa<RESET>\n <RED>11<RESET>aa\n \n-<RED>11<RESET>aa\n-<RED>11<RESET>aa\n+<RED>11<RESET>aa<RED>11<RESET>\n+aa\n\n\nLucian Poston (1):\n  t4034: Test parsing words following newline\n\n t/t4034-diff-words.sh | 30 ++++++++++++++++++++++++++++++\n 1 file changed, 30 insertions(+)\n\n-- \n2.4.10\n"},{"id":"272286","messageId":"1445910013-13382-2-git-send-email-lucian.poston@gmail.com","threadId":"40653","inReplyTo":"1445910013-13382-1-git-send-email-lucian.poston@gmail.com","subject":"[PATCH] t4034: Test parsing words following newline","fromName":"Lucian Poston","fromEmail":"lucian.poston@gmail.com","sentAt":"2015-10-27T01:40:13Z","receivedAt":"2015-10-27T01:40:13Z","isPatch":true,"sender":{"key":"lucian.poston@gmail.com","avatar":"https://avatars.githubusercontent.com/u/646121?v=4"},"body":"Add test that shows diff --word-diff's inconsistent placement of removed\nwords. This occurs when both the removed word is first on its line and the\nprevious line has a removed word.\n\nSigned-off-by: Lucian Poston <lucian.poston@gmail.com>\n---\n t/t4034-diff-words.sh | 30 ++++++++++++++++++++++++++++++\n 1 file changed, 30 insertions(+)\n\ndiff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\nindex f2f55fc..8d9f1b7 100755\n--- a/t/t4034-diff-words.sh\n+++ b/t/t4034-diff-words.sh\n@@ -265,6 +265,36 @@ test_expect_success 'test parsing words for newline' '\n \tword_diff --color-words=\"a+\"\n '\n \n+test_expect_success 'test parsing words following newline' '\n+\tcat >pre <<-\\EOF &&\n+\t\t11aa\n+\t\t11aa\n+\t\t\n+\t\t11aa\n+\t\t11aa\n+\tEOF\n+\tcat >post <<-\\EOF &&\n+\t\t11aa\n+\t\taa\n+\t\t\n+\t\taa\n+\t\taa\n+\tEOF\n+\tcat >expect <<-\\EOF &&\n+\t\t<BOLD>diff --git a/pre b/post<RESET>\n+\t\t<BOLD>index 2e0acd4..f6e6721 100644<RESET>\n+\t\t<BOLD>--- a/pre<RESET>\n+\t\t<BOLD>+++ b/post<RESET>\n+\t\t<CYAN>@@ -1,5 +1,5 @@<RESET>\n+\t\t11aa<RESET>\n+\t\t<RED>11<RESET>aa\n+\t\t\n+\t\t<RED>11<RESET>aa\n+\t\t<RED>11<RESET>aa\n+\tEOF\n+\tword_diff --color-words=\"a+|1+\"\n+'\n+\n test_expect_success 'test when words are only removed at the end' '\n \techo \"(:\" >pre &&\n \techo \"(\" >post &&\n-- \n2.4.10\n"}]}