threads / bug / 66494

[BUG] git diff go mad compared to diffutils

Subject: [BUG] git diff go mad compared to diffutils

## tl;dr

A user whose patch diffed badly against GNU diff was pointed to the histogram algorithm, which gave a cleaner result. Read the story.

replies: 1people: 2as markdown or json

David Yang· Oct 9, 2026, 02:38 UTC · lore
Hello Git community,

I'm using git 2.53.0 on Debian testing. During preparing a new version for https://lore.kernel.org/all/20261001204851.2576101-3-mmyangfl@gmail.com/ , I've noticed git generated unusual distorted patch https://github.com/yangfl/linux/commit/01e2de4664f60528dd9b4f15b5995fc5cb0e7b4f . As you may see, GitHub diff is distorted as well.

With diffutils 3.12 (diff -u old new) I can get nice diff file with delection only, just like the v2 patch.

Should this be considered a bug?
Thanks
Toon Claes· Oct 13, 2026, 05:57 UTC · re: David Yang · lore

Re: [BUG] git diff go mad compared to diffutils

David Yang <mmyangfl@gmail.com> writes:
Show 10 quoted lines
> Hello Git community,
>
> I'm using git 2.53.0 on Debian testing. During preparing a new version
> for https://lore.kernel.org/all/20261001204851.2576101-3-mmyangfl@gmail.com/
> , I've noticed git generated unusual distorted patch
> https://github.com/yangfl/linux/commit/01e2de4664f60528dd9b4f15b5995fc5cb0e7b4f
> . As you may see, GitHub diff is distorted as well.
>
> With diffutils 3.12 (diff -u old new) I can get nice diff file with
> delection only, just like the v2 patch.

I think this depends on the used diff algorithm. By default git uses 'myers', this isn't really great. If you run:

   git diff --diff-algorithm=histogram \
     9142c2f8f84bf4eafe23e9d68b6ba016a60300c0 \
     01e2de4664f60528dd9b4f15b5995fc5cb0e7b4f \
     -- drivers/net/dsa/motorcomm/chip.c
The diff is cleaner.
> Should this be considered a bug?

So I don't consider this a bug. Git is just stuck at an ancient default algorithm.

-- 
Laters,
Toon

← back to recent threads