git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Iago-lito <iago-lito@cleb.io>
Cc: git@vger.kernel.org
Subject: Re: `git apply -p` doesn't remove source prefix in 'rename' diff entries.
Date: Mon, 04 Nov 2024 16:36:20 -0800	[thread overview]
Message-ID: <xmqqjzdiv7nf.fsf@gitster.g> (raw)
In-Reply-To: <d67e133c-f287-4009-9244-eaeffd84daeb@cleb.io> (iago-lito@cleb.io's message of "Mon, 4 Nov 2024 21:35:47 +0100")

Iago-lito <iago-lito@cleb.io> writes:

> Hello @Junio, and thank you for feedback :)
>
> If I understand correctly, you are suggesting that `git diff`/`git
> apply` are behaving correctly here, but they might not be the right
> tool for the job?

No.  

"git diff --no-index" is giving "wrong" information in the
rename/copy extended diff headers, but regular "git diff" is
perfectly fine.  Also "git apply" is perfectly fine.

And the "wrong"-ness above is in the eyes of beholder, in the sense
that the original folks who coaxed "these two directories are not
controlled by Git, but unlike GNU diff, "git diff" has a few nice
bells and whistles, so instead of adding these properly to GNU diff,
abuse "git diff" to add a mode where two directories are compared"
probably did not view that "git diff --no-index X Y" must be
equivalent to committing the contents of X first and then Y next,
and then doing "git show" on the resulting history.

I do not know why being different and showing X and Y as part of the
paths reported on the "rename from" etc. extended diff headers could
sometimes be useful, but they must have had some use cases I am not
seeing offhand.

So in order to lift this "wrong"-ness, you'd probably want an option
to the "no-index" mode of the "git diff" (in "diff-no-index.c") to
omit the leading directory name (i.e. X/ and Y/) from these
rename/copy extended diff headers.  Then your toy example would work
when the "git diff --no-index --fixed-rename-copy-path-info" is used.

      reply	other threads:[~2024-11-05  0:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-01  0:17 `git apply -p` doesn't remove source prefix in 'rename' diff entries Iago-lito
2024-11-01  7:05 ` Junio C Hamano
2024-11-04 20:35   ` Iago-lito
2024-11-05  0:36     ` Junio C Hamano [this message]

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=xmqqjzdiv7nf.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=iago-lito@cleb.io \
    /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;
as well as URLs for NNTP newsgroup(s).