All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Hao Lee <haolee.swjtu@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [BUG] `git diff` treats an unchanged line as modified
Date: Tue, 24 Dec 2019 11:34:43 -0800	[thread overview]
Message-ID: <xmqqy2v14iwc.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <CA+PpKPm0_zXr978Mw8h7owHBChx-uqVCdjrtuh45uOS-A_0qrA@mail.gmail.com> (Hao Lee's message of "Wed, 25 Dec 2019 01:50:29 +0800")

Hao Lee <haolee.swjtu@gmail.com> writes:

> I think the latter is correct because the fifth line is not changed
> and it's still a line which only contains a whitespace.

As long as lines that begin with "-" and " " match what the 'old'
file has, and replacing them with lines that begin with " " and
"+" in the 'old' file yields the 'new' file, any patch is "correct".

IOW, there is no *single* diff output that is correct.

Among many "correct" diff output, there are ones that readers find
them easier to understand and those that look suboptimal.  The
differences are often personal tastes.

"git diff" has options to tweak heuristics it uses to choose among
many "correct" diff outputs, like --patience, --histogram, etc.
Perhaps using one of them would produce one that match your taste
better?


  reply	other threads:[~2019-12-24 19:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-24 17:50 [BUG] `git diff` treats an unchanged line as modified Hao Lee
2019-12-24 19:34 ` Junio C Hamano [this message]
2019-12-25 15:26   ` Hao Lee

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=xmqqy2v14iwc.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=haolee.swjtu@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.