From: Junio C Hamano <gitster@pobox.com>
To: Chris Torek <chris.torek@gmail.com>
Cc: Michael Montalbo <mmontalbo@gmail.com>,
Johannes Sixt <j6t@kdbg.org>,
vincent@vinc17.net, git@vger.kernel.org
Subject: Re: [BUG] "git diff --word-diff" gives a diff while they are only space changes
Date: Tue, 19 May 2026 12:11:15 +0900 [thread overview]
Message-ID: <xmqqo6ic8564.fsf@gitster.g> (raw)
In-Reply-To: <CAPx1Gvd_FqnsjCkpAA5uy7aDz9oQnWx7WTvKk-kLWemkqF9PsQ@mail.gmail.com> (Chris Torek's message of "Mon, 18 May 2026 19:31:35 -0700")
Chris Torek <chris.torek@gmail.com> writes:
> Call it an "implementation note" (or, if you like, a "practical
> consideration"?).
> Something along these lines might work...
>
> Implementation Note
>
> The --word-diff option currently operates by taking the same
> line by line diff that you get without the option, then massaging
> the result into a word-by-word difference. This may cause an
> unnecessarily-larger diff than you would see with a more-clever
> implementation. If and when Git acquires a more-clever
> implementation, the output may change. Note that this is
> similar to the --diff-algorithm option, which may change the
> output.
>
> Regardless of which algorithm is used, _any_ diff simply shows
> _a_ way to achieve some particular change. It's impossible for
> any algorithm to tell whether someone deleted two lines and
> then put one back exactly as it appeared earlier, saving the
> resulting text, vs deleting a single line, for instance. Only a
> keystroke-by-keystroke logger would be able to tell what the
> human operator actually typed into some editor. Git does
> not have that information, and having it is not desired.
>
> Chris
I understand your frustration in the second paragraph ;-) but let's
not go there. The first paragraph is excellent. It gives readers a
clear enough explanation to understand what is happening and stop
complaining where there is nothing to complain about (which is
already hinted by the "Note that" at the end).
next prev parent reply other threads:[~2026-05-19 3:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 20:56 [BUG] "git diff --word-diff" gives a diff while they are only space changes Michael Montalbo
2026-05-12 21:17 ` Vincent Lefevre
2026-05-13 15:52 ` Michael Montalbo
2026-05-14 7:37 ` Junio C Hamano
2026-05-14 9:55 ` Vincent Lefevre
2026-05-15 13:22 ` Phillip Wood
2026-05-18 3:30 ` Michael Montalbo
2026-05-18 7:30 ` Johannes Sixt
2026-05-19 2:07 ` Michael Montalbo
2026-05-19 2:31 ` Chris Torek
2026-05-19 3:11 ` Junio C Hamano [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-05-06 1:09 Vincent Lefevre
2026-05-08 12:48 ` Johannes Sixt
2026-05-08 21:39 ` Vincent Lefevre
2026-05-09 6:16 ` Johannes Sixt
2026-05-09 15:55 ` Vincent Lefevre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqo6ic8564.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=chris.torek@gmail.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=mmontalbo@gmail.com \
--cc=vincent@vinc17.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox