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

Incorrect unified diff when run with "--find-copies-harder"

From
DPDaniel Penkin <dpenkin@gmail.com>
Date
Jun 24, 2018, 10:36 UTC
Message-ID
<CAL78Jw0mQWxO4xkzFBoG0Oe4wjomUGj=dP5ufdUrE5Ku0GGEtg@mail.gmail.com>
Hello,

I believe I found a bug in how Git represents a diff when invoked with "--find-copies-harder" parameter. Specifically, the unified diff header of a hunk contains an extra piece of text which appears to be a line from the context (i.e. unchanged line), something like this:

    > git diff --find-copies-harder d00ca3f 20fb313
    diff --git a/test.txt b/copy.txt
    similarity index 81%
    copy from test.txt
    copy to copy.txt
    index 734156d..43a3f9d 100644
    --- a/test.txt
    +++ b/copy.txt
    @@ -2,6 +2,7 @@ line 1
     line 2
     line 3
     line 4
    +added line
     line 5
     line 6
     line 7
Note "line 1" after the standard unified diff header.

I prepared a sample repository with a minimal file I can reproduce this problem with: https://bitbucket.org/dpenkin/find-copies-harder-bug

I'm running Git 2.18.0 on a macOS, but I also tried with Git 2.15.0 and 2.8.6 running on Alpine Linux and was able to reproduce the same problem.

Please advise whether this is expected output or is indeed a bug.
Thank you.

Kind regards, Daniil Penkin

Next: Andrei Rybak
Message 1 of 3 in “Incorrect unified diff when run with "--find-copies-harder"”
  1. Daniel PenkinJun 24, 2018
  2. Andrei RybakJun 24, 2018
  3. Daniel PenkinJun 24, 2018

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.