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

Is --minimal ever not the right thing?

From
Tao Klerks <tao@klerks.biz>
Date
Dec 19, 2023, 16:10 UTC
Message-ID
<CAPMMpohbQK+3o46iiY+0o=vS+UC_HBB=CxsNT_hAb5dDz+514Q@mail.gmail.com>
Hi folks,

A user today showed me a situation where `git diff` (and `git blame`) seemed to be doing the wrong thing: where two big blocks of text were removed from a file, leaving 4 lines untouched in the middle, the default diff was noting all three regions as lines removed, with those 4 "untouched" lines as *added* in the same place.

We compared to another diffing tool, p4merge, and that was showing "the right thing" - two deleted regions with untouched lines in the middle.

We realized that `--minimal` does "the right thing" in git, and you can set up `diff.algorithm` config to use it by default in `git diff` (although `git blame` doesn't currently/yet support it... a small enhancement opportunity there :) ), but that raises two questions:

1. Is there any practical reason for any user *not* to set
`diff.algorithm` to `minimal`? Has anyone ever done an analysis of the
performance cost (or "diff readability cost", if that is a thing) of
"minimal" vs "default"?
2. If "minimal" is just better, and its higher computational cost is
effectively trivial, then why wouldn't we change the default?

I suspect this comes down to situations where git does big diffs behind the scenes...? But I don't know offhand.

Any feedback would be most appreciated!

Thanks, Tao

Next: Mike Castle
Message 1 of 4 in “Is --minimal ever not the right thing?”
  1. Tao KlerksDec 19, 2023
  2. Mike CastleDec 19, 2023
  3. Elijah NewrenDec 19, 2023
  4. Konstantin TokarevDec 19, 2023

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.