From: Elijah Newren <newren@gmail.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: "Peregi Tamás" <petamas@gmail.com>,
git@vger.kernel.org, "Patrick Steinhardt" <ps@pks.im>,
"Jeff King" <peff@peff.net>, "René Scharfe" <l.s.r@web.de>
Subject: Re: Inconsistent handling of corrupt patches based on line endings
Date: Mon, 28 Oct 2024 11:39:47 -0700 [thread overview]
Message-ID: <CABPp-BFB+eG7WVJFm3EBfgKzuspAYn9KpDHodpgKuFmWefARBw@mail.gmail.com> (raw)
In-Reply-To: <Zx/TwhuG4Ni7mf6F@nand.local>
On Mon, Oct 28, 2024 at 11:11 AM Taylor Blau <me@ttaylorr.com> wrote:
>
> On Mon, Oct 28, 2024 at 05:57:54PM +0100, Peregi Tamás wrote:
> > Hi all,
> >
> > I might've found an inconsistency in how git-apply treats corrupt patches
> > (representing empty context lines with completely empty lines instead of
> > lines containing a single space - usually a result of a "trim trailing
> > whitespace" editor setting) based on whether the patch file uses
> > Windows-style line endings (CRLF) or Unix-style line endings (LF only).
>
> Let's see if any recent apply.c folks have thoughts...:
>
> $ git shortlog -nse --no-merges --since=3.years.ago.. -- apply.c
> 21 Elijah Newren <newren@gmail.com>
> 12 Patrick Steinhardt <ps@pks.im>
> 7 Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> 5 Junio C Hamano <gitster@pobox.com>
> 4 Jeff King <peff@peff.net>
> 4 René Scharfe <l.s.r@web.de>
...and thus we learn why no one wanted to clean up the header files in
git.git before me. ;-)
I believe this behavior was caused by:
$ git log -1 b507b465f7831612b9d9fc643e3e5218b64e5bfa
commit b507b465f7831612b9d9fc643e3e5218b64e5bfa
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Thu Oct 19 19:26:08 2006 -0700
git-apply: prepare for upcoming GNU diff -u format change.
The latest GNU diff from CVS emits an empty line to express
an empty context line, instead of more traditional "single
white space followed by a newline". Do not get broken by it.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
That code special-cased a line containing '\n' but not a line
containing only '\r\n'.
As to whether that's correct, personally I'd rather only special case
workaround important existing clients. Back in 2006, working with GNU
diff was incredibly important, and I'd say is still important today.
I can see Peregi's comment that this make line ending slightly
inconsistent, but I feel like the blank-line handling is a workaround
for an existing client we want to interoperate with and absent a
similar important client with mis-behaving '\r\n'-only lines, I
wouldn't be interested in adding support for it. But that's just my
off-the-cuff feeling and I don't feel strongly about it. Further, all
but one of my contributions above were mere header changes, so if
others have other opinions, they should probably be weighted more
heavily than mine on this topic.
next prev parent reply other threads:[~2024-10-28 18:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 16:57 Inconsistent handling of corrupt patches based on line endings Peregi Tamás
2024-10-28 18:11 ` Taylor Blau
2024-10-28 18:39 ` Elijah Newren [this message]
2024-10-28 22:07 ` René Scharfe
2024-10-28 22:59 ` Junio C Hamano
2024-10-29 16:32 ` Torsten Bögershausen
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=CABPp-BFB+eG7WVJFm3EBfgKzuspAYn9KpDHodpgKuFmWefARBw@mail.gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
--cc=petamas@gmail.com \
--cc=ps@pks.im \
/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).