From: Junio C Hamano <gitster@pobox.com>
To: Elijah Newren <newren@gmail.com>
Cc: Emanuel Czirai <correabuscar+gitML@gmail.com>, git@vger.kernel.org
Subject: Re: `git diff`/`git apply` can generate/apply ambiguous hunks (ie. in the wrong place) (just like gnu diff/patch)
Date: Fri, 05 Jul 2024 22:43:35 -0700 [thread overview]
Message-ID: <xmqq5xtj5b3s.fsf@gitster.g> (raw)
In-Reply-To: <CABPp-BGVdQZCr=0NzY9vpUJqaH+5yxJdpvfUqqhtWB4V=nkwDw@mail.gmail.com> (Elijah Newren's message of "Thu, 4 Jul 2024 13:07:52 -0700")
Elijah Newren <newren@gmail.com> writes:
> Yes, this is already known. In fact, it was one of the big reasons we
> changed the default backend in rebase from apply to merge. From the
> git-rebase manpage:
Not exactly on topic of the discussion, but I see a few things
problematic in this part, and as I already invested some time
reading it, I'd leave #leftoverbits comment here.
> ```
> Context
> The apply backend works by creating a sequence of patches (by calling
> format-patch internally), and then applying the patches in sequence
> (calling am internally). Patches are composed of multiple hunks, each
`am` should be some marked-up to stand out. It would be even better
to spell it out as `git am`.
> with line numbers, a context region, and the actual changes. The line
> numbers have to be taken with some fuzz, since the other side will
"fuzz" -> "offset"
In the context of discussing patch application, `fuzz` is a term of
art. It is the number of context lines you (the patch applicator)
allow the machinery to allow to be different between the patch and
the preimage. Git allows *absolutely* no fuzz and there is not even
an option to loosen this (this is philosophical design decision
originating back in Linus's days).
This part is talking about something different. `offset` is another
term of art and refers to the difference between the beginning line
number recorded in the hunk header, and the actual line in the preimage
the patch applies to. Unless you are applying to the same preimage
as where the patch was taken from, `offset` being non-zero is
perfectly normal, but Git (and other patch applicators) try to
minimize the offset.
next prev parent reply other threads:[~2024-07-06 5:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-03 15:24 `git diff`/`git apply` can generate/apply ambiguous hunks (ie. in the wrong place) (just like gnu diff/patch) Emanuel Czirai
2024-07-03 15:55 ` rsbecker
2024-07-03 16:22 ` Emanuel Attila Czirai
2024-07-03 21:01 ` Johannes Sixt
2024-07-04 7:15 ` Emanuel Czirai
2024-07-04 20:07 ` Elijah Newren
2024-07-04 21:38 ` Emanuel Czirai
2024-07-06 5:43 ` Junio C Hamano [this message]
[not found] <CAFjaU5sU04-aUyfHLhYkR7jSqB18He-aEt=B_C41DkMnvm2zFQ@mail.gmail.com>
2024-07-04 10:24 ` Emanuel Czirai
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=xmqq5xtj5b3s.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=correabuscar+gitML@gmail.com \
--cc=git@vger.kernel.org \
--cc=newren@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 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).