git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Fwd: diff not finding difference

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Sep 25, 2015, 10:25 UTC
Message-ID
<560520FC.7050501@drmicha.warpmail.net>
In-Reply-To
<8abeb16d123a602ee11dab3f93dab51e@dscho.org>
Johannes Schindelin venit, vidit, dixit 25.09.2015 12:11:
Show 17 quoted lines
> Hi Jack Adrian,
> 
> On 2015-09-24 23:09, Jack Adrian Zappa wrote:
>> This is a weird one:
>> 
>> [file-1 begin]
>> 
>> abcd efg hijklmnop
>> 
>> [file-1 end]
>> 
>> [file-2 begin]
>> 
>> blah blah blah 
>> /////////////////////////////////////////////////////////////////////////////////
>>
>> 
abdc boo ya!
Show 32 quoted lines
>> 
>> [file-2 end]
>> 
>> Do a diff between these and it won't find any difference.
>> 
>> Same with the following two lines, each in a different file: sabc
>> fed ghi jkl abc def ghi jkl
>> 
>> I first noticed this on the command line git and then in VS2013.
>> The original problem was like my first example.  The files were
>> much longer, but all that git would see is the addition of the line
>> of ////..., but not the removal of the original line.
>> 
>> I've tried some other simple file changes with similar results. 
>> Something seems to be definitely broken in git diff. :(
> 
> You 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.
> 
> Now, 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).
> 
> But `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

Ah, now is a good time to rename my (shell) alias "gdiff" for "git diff --no-index" to dschodiff.

Thanks, Dscho :) Michael

P.S.: Note that dschodiff works perfectly even outside a git working directory, with all the --color-words and whitespace goodness and what not!

Previous: Johannes Schindelin
Message 4 of 4 in “Fwd: diff not finding difference”
  1. Jack Adrian ZappaSep 24, 2015
  2. Jack Adrian ZappaSep 24, 2015
  3. Johannes SchindelinSep 25, 2015
  4. Michael J GruberSep 25, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.