{"thread":{"id":"40425","subject":"Fwd: diff not finding difference","startedAt":"2015-09-24T21:09:15Z","lastAt":"2015-09-25T10:25:00Z","messageCount":4,"participants":["Jack Adrian Zappa","Johannes Schindelin","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"270708","messageId":"CAKepmajegSMO91YZOe+P_BH2kzzR=RMqCE94XRQSfZzOVYKt6A@mail.gmail.com","threadId":"40425","inReplyTo":"CAKepmajSPgGK-DqR3Bxf2Xqxj2Gz0MazRNxM6wsVcSiBQsoE4Q@mail.gmail.com","subject":"Fwd: diff not finding difference","fromName":"Jack Adrian Zappa","fromEmail":"adrianh.bsc@gmail.com","sentAt":"2015-09-24T21:09:15Z","receivedAt":"2015-09-24T21:09:15Z","isPatch":false,"sender":{"key":"adrianh.bsc@gmail.com","avatar":null},"body":"This is a weird one:\n\n[file-1 begin]\n\nabcd efg hijklmnop\n\n[file-1 end]\n\n[file-2 begin]\n\nblah blah blah\n/////////////////////////////////////////////////////////////////////////////////\nabdc boo ya!\n\n[file-2 end]\n\nDo a diff between these and it won't find any difference.\n\nSame with the following two lines, each in a different file:\nsabc fed ghi jkl\nabc def ghi jkl\n\nI first noticed this on the command line git and then in VS2013.  The\noriginal problem was like my first example.  The files were much\nlonger, but all that git would see is the addition of the line of\n////..., but not the removal of the original line.\n\nI've tried some other simple file changes with similar results.\nSomething seems to be definitely broken in git diff. :(\n\nCommand line version of git is 1.9.5 msysgit.0.\n\n\nA\n"},{"id":"270719","messageId":"CAKepmaihyVS3hiAS4bZUfvt-r0ZWycPRkWnokaS7Gx2hEnjT3w@mail.gmail.com","threadId":"40425","inReplyTo":"CAKepmajegSMO91YZOe+P_BH2kzzR=RMqCE94XRQSfZzOVYKt6A@mail.gmail.com","subject":"Re: diff not finding difference","fromName":"Jack Adrian Zappa","fromEmail":"adrianh.bsc@gmail.com","sentAt":"2015-09-24T21:12:18Z","receivedAt":"2015-09-24T21:12:18Z","isPatch":false,"sender":{"key":"adrianh.bsc@gmail.com","avatar":null},"body":"On Thu, Sep 24, 2015 at 5:09 PM, Jack Adrian Zappa\n<adrianh.bsc@gmail.com> wrote:\n> This is a weird one:\n>\n> [file-1 begin]\n>\n> abcd efg hijklmnop\n>\n> [file-1 end]\n>\n> [file-2 begin]\n>\n> blah blah blah\n> /////////////////////////////////////////////////////////////////////////////////\n> abdc boo ya!\n>\n> [file-2 end]\n>\n> Do a diff between these and it won't find any difference.\n>\n> Same with the following two lines, each in a different file:\n> sabc fed ghi jkl\n> abc def ghi jkl\n>\n> I first noticed this on the command line git and then in VS2013.  The\n> original problem was like my first example.  The files were much\n> longer, but all that git would see is the addition of the line of\n> ////..., but not the removal of the original line.\n>\n> I've tried some other simple file changes with similar results.\n> Something seems to be definitely broken in git diff. :(\n>\n> Command line version of git is 1.9.5 msysgit.0.\n>\n>\n> A\n\nBTW, I've upgraded to git version 2.5.3.windows.1 and the problem\nstill persists.\n\n\nA\n"},{"id":"270746","messageId":"8abeb16d123a602ee11dab3f93dab51e@dscho.org","threadId":"40425","inReplyTo":"CAKepmajegSMO91YZOe+P_BH2kzzR=RMqCE94XRQSfZzOVYKt6A@mail.gmail.com","subject":"Re: Fwd: diff not finding difference","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-09-25T10:11:33Z","receivedAt":"2015-09-25T10:11:33Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Jack Adrian,\n\nOn 2015-09-24 23:09, Jack Adrian Zappa wrote:\n> This is a weird one:\n> \n> [file-1 begin]\n> \n> abcd efg hijklmnop\n> \n> [file-1 end]\n> \n> [file-2 begin]\n> \n> blah blah blah\n> /////////////////////////////////////////////////////////////////////////////////\n> abdc boo ya!\n> \n> [file-2 end]\n> \n> Do a diff between these and it won't find any difference.\n> \n> Same with the following two lines, each in a different file:\n> sabc fed ghi jkl\n> abc def ghi jkl\n> \n> I first noticed this on the command line git and then in VS2013.  The\n> original problem was like my first example.  The files were much\n> longer, but all that git would see is the addition of the line of\n> ////..., but not the removal of the original line.\n> \n> I've tried some other simple file changes with similar results.\n> Something seems to be definitely broken in git diff. :(\n\nYou might want to show your exact command-line invocation, i.e. the full information. I suspect that you missed the fact that `git diff a b` does not compare the file a to the file b, but instead it compares both a and b to what is recorded in the index. With one quirk: if the files a and b are not even recorded in the index, `git diff` will output nothing.\n\nNow, the really confusing part for you was probably that your `file-2` *was* recorded in the index (maybe you made a backup copy with the extra file extension `.bak` or some such, and then called `git diff my-file.bak my-file` where `my-file` *actually is tracked by Git* but `my-file.bak` is not).\n\nBut `git diff` has so nice features that I wanted to use it myself to compare files or directories. That is why I introduced the `--no-index` option, years ago. And so I suspect that you called\n\n    git diff file-1 file-2\n\nwhen you actually wanted to call\n\n    git diff --no-index file-1 file-2\n\nHere is my shell session to verify that `git diff` works as designed:\n\n```\nme@work $ cat >file-1\n\nabcd efg hijklmnop\n\nme@work $ cat >file-2\n\nblah blah blah\n/////////////////////////////////////////////////////////////////////////////////\nabdc boo ya!\n\nme@work $ git diff --no-index file-1 file-2\ndiff --git a/file-1 b/file-2\nindex 80ea2bc..f7fd7eb 100644\n--- a/file-1\n+++ b/file-2\n@@ -1,3 +1,5 @@\n\n-abcd efg hijklmnop\n+blah blah blah\n+/////////////////////////////////////////////////////////////////////////////////\n+abdc boo ya!\n\nme@work $\n```\n\nPlease note that I ended the file contents for both `cat` calls [*1*] with a `Ctrl+D` which you cannot see in the pasted lines.\n\nCiao,\nJohannes\n\nFootnote *1*: Can you believe that I wanted to make that pun for at least ten years now?\n"},{"id":"270747","messageId":"560520FC.7050501@drmicha.warpmail.net","threadId":"40425","inReplyTo":"8abeb16d123a602ee11dab3f93dab51e@dscho.org","subject":"Re: Fwd: diff not finding difference","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2015-09-25T10:25:00Z","receivedAt":"2015-09-25T10:25:00Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Johannes Schindelin venit, vidit, dixit 25.09.2015 12:11:\n> Hi Jack Adrian,\n> \n> On 2015-09-24 23:09, Jack Adrian Zappa wrote:\n>> This is a weird one:\n>> \n>> [file-1 begin]\n>> \n>> abcd efg hijklmnop\n>> \n>> [file-1 end]\n>> \n>> [file-2 begin]\n>> \n>> blah blah blah \n>> /////////////////////////////////////////////////////////////////////////////////\n>>\n>> \nabdc boo ya!\n>> \n>> [file-2 end]\n>> \n>> Do a diff between these and it won't find any difference.\n>> \n>> Same with the following two lines, each in a different file: sabc\n>> fed ghi jkl abc def ghi jkl\n>> \n>> I first noticed this on the command line git and then in VS2013.\n>> The original problem was like my first example.  The files were\n>> much longer, but all that git would see is the addition of the line\n>> of ////..., but not the removal of the original line.\n>> \n>> I've tried some other simple file changes with similar results. \n>> Something seems to be definitely broken in git diff. :(\n> \n> You might want to show your exact command-line invocation, i.e. the\n> full information. I suspect that you missed the fact that `git diff a\n> b` does not compare the file a to the file b, but instead it compares\n> both a and b to what is recorded in the index. With one quirk: if the\n> files a and b are not even recorded in the index, `git diff` will\n> output nothing.\n> \n> Now, the really confusing part for you was probably that your\n> `file-2` *was* recorded in the index (maybe you made a backup copy\n> with the extra file extension `.bak` or some such, and then called\n> `git diff my-file.bak my-file` where `my-file` *actually is tracked\n> by Git* but `my-file.bak` is not).\n> \n> But `git diff` has so nice features that I wanted to use it myself to\n> compare files or directories. That is why I introduced the\n> `--no-index` option, years ago. And so I suspect that you called\n\nAh, now is a good time to rename my (shell) alias \"gdiff\" for \"git diff\n--no-index\" to dschodiff.\n\nThanks, Dscho :)\nMichael\n\nP.S.: Note that dschodiff works perfectly even outside a git working\ndirectory, with all the --color-words and whitespace goodness and what not!\n"}]}