Search code examples
gitgit-range-diff

Why git range-diff does not show changes in commit?


I compare two ranges:

enter image description here

Why git range-diff does not show difference? when 3a8c and 2340 commits are different:

enter image description here

enter image description here


Solution

  • We can see from the first image that git range-diff has decided that one patch was completely deleted in the original range, and a completely different new patch was supplied in its place. This is what:

    1:  2340cb53 <  -:  -------- Added placeholder for send form
    -:  -------- >  1:  3a8c358d Added placeholder for send form
    

    means. Had Git decided that commits 2340cb53 and 3a8c358d were different forms of the same commit, you would have seen:

    1:  2340cb53 !  1:  3a8c358d Added placeholder for send form
    

    You might next ask: Why are these considered different patches, instead of a modification of a single patch? For that, we go to the DESCRIPTION section of the documentation:1

    To that end, it first finds pairs of commits from both commit ranges that correspond with each other. Two commits are said to correspond when the diff between their patches (i.e. the author information, the commit message and the commit diff) is reasonably small compared to the patches' size.

    Reading a bit further, into the OPTIONS section, we find:

    --creation-factor=<percent>

    Set the creation/deletion cost fudge factor to <percent>. Defaults to 60. Try a larger value if git range-diff erroneously considers a large change a total rewrite (deletion of one commit and addition of another), and a smaller one in the reverse case. See the ``Algorithm`` section below for an explanation why this is needed.

    So you should re-run your command with a larger --creation-factor.

    enter image description here


    1Git documentation uses, here, the word "correspond" where I generally use the word "identity", referring to the philosophical problem of identity over time. See the Wikipedia entry for the Ship of Theseus. This same problem crops up in simple commit-vs-commit diffs: how do we know that some/path/to/file.ext in commit L on the left is "the same" file as different/path/to/name.extension in commit R on the right? The ultimate answer is always that we don't know this at all; we must use some method to make a guess. For file-vs-file, as in the commit-vs-commit case, Git's primary method of guessing is to use the two files' path names. For range-vs-range, that method does not work.