{"thread":{"id":"55537","subject":"git word diff bug?","startedAt":"2021-04-21T18:13:51Z","lastAt":"2021-04-21T18:13:51Z","messageCount":1,"participants":["Count of San Francisco"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"422613","messageId":"2f6fbf1d-a3b9-9766-9593-44ac69ba4e83@gmail.com","threadId":"55537","inReplyTo":null,"subject":"git word diff bug?","fromName":"Count of San Francisco","fromEmail":"countofsanfrancisco@gmail.com","sentAt":"2021-04-21T18:13:45Z","receivedAt":"2021-04-21T18:13:51Z","isPatch":false,"sender":{"key":"countofsanfrancisco@gmail.com","avatar":null},"body":"Hi All,\n\nHere is my \"git bugreport\":\n\nThank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n   git diff --word-diff=porcelain file0.txt file1.txt\n     or\n   git diff --word-diff file0.txt file1.txt\n\nWhat did you expect to happen? (Expected behavior)\n\n   I expected the diff for porcelain or default word-diff to be clear on \nwhich lines got removed and which changes belong to which line. I \nexplain more in details below.\n\nWhat happened instead? (Actual behavior)\n\n   The diff was not clear.\n\nWhat's different between what you expected and what actually happened?\n\n   The diff made it looked like all the removed text were on one line \nand a later change in a line look like it was meant for a different \nline. When in fact, the later changes were for the same line (i.e. the \nfirst line). More details below.\n\nAnything else you want to add:\n\nHere are the details to reproduce and more details on how I interpreted \nthe diff. If I am writing a script to highlight changes or to do extra \nprocessing for my specific use case, my script would get confused as to \nwhat really changed.\n\nfile0.txt content:\n*** Begin Content *** --> this line is not in the actual file but just a \nmarker here for clarity.\nThe fox jumped over the wall.\nBlah1e32\nq432423\nqe23234\n  233\n253\n345235\n\n53243\nafsfffas\n*** End Content ****\n\nfile1.txt content:\n*** Begin Content ***\nThe fox jumped over the river.\n   He made it over.\n*** End Content ****\n\ngit diff --word-diff file0.txt file1.txt produced this:\ndiff --git a/file0.txt b/file1.txt\nindex c8756ba..3413f10 100644\n--- a/file0.txt\n+++ b/file1.txt\n@@ -1,11 +1,2 @@\nThe fox jumped over the [-wall.-]\n[-Blah1e32-]\n[-q432423-]\n[-qe23234-]\n[- 233-]\n[-253-]\n[-345235-]\n\n[-53243-]\n[-afsfffas-]{+river.+}\n{+  He made it over.+}\n\nThe diff above does not make it clear that the \"{+river+}\" is really to \nbe appended (or related) to the first line.\nI expected the first diff line to look like this:\nThe fox jumped over the [-wall.-]{+river+} and the rest of the lines are \ndelete lines.\n\ngit diff --word-diff=porcelain file0.txt file1.txt produced this:\ndiff --git a/file0.txt b/file1.txt\nindex c8756ba..3413f10 100644\n--- a/file0.txt\n+++ b/file1.txt\n@@ -1,11 +1,2 @@\n  The fox jumped over the\n-wall.\n~\n-Blah1e32\n~\n-q432423\n~\n-qe23234\n~\n- 233\n~\n-253\n~\n-345235\n~\n~\n-53243\n~\n-afsfffas\n+river.\n~\n+  He made it over.\n~\n\nThis is more non-discernable. The git diff --help documentation says \nthat \"Newlines in the input are represented by a tilde ~ on a line of \nits own\". So a script would see the '~' character and interpret that as \na new line. The script would have mistaken the \"+river\" for a different \nline. The git diff --help documentation does not explain what to do in \nthis scenario.\n\nI expected this:\n  The fox jumped over the\n-wall.\n+river.\n~\n\nIs this a bug? If not, how do I make the distinction that the {+river+} \n(in the first case) and the +river (in the 2nd case) is really for the \nfirst line?\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.30.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 \nPST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64\ncompiler info: clang: 12.0.0 (clang-1200.0.32.28)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /usr/local/bin/bash\n\n\n[Enabled Hooks]\nnot run from a git repository - no hooks to show\n"}]}