From: Phillip Wood <phillip.wood123@gmail.com>
To: Tanga Joris <tangajoris@gmail.com>, phillip.wood@dunelm.org.uk
Cc: git@vger.kernel.org, gitster@pobox.com,
jackrawlings2011@gmail.com, christian.couder@gmail.com,
siddharthasthana31@gmail.com, kaartic.sivaraam@gmail.com,
usmanakinyemi202@gmail.com
Subject: Re: [Outreachy PATCH 1/2] apply: do not keep names from an unused "diff --git" line
Date: Mon, 9 Nov 2026 14:31:22 +0000 [thread overview]
Message-ID: <d5bb8fe0-7706-4e3d-b471-ad004411a9ed@gmail.com> (raw)
In-Reply-To: <CAKrRMNr5VJmvws0asHgmDxCNxo19ctGTpM2eoTMT3iQ5v2cagQ@mail.gmail.com>
Hi Tanga
On 09/11/2026 13:13, Tanga Joris wrote:
> On Mon, 9 Nov 2026 at 13:52, Phillip Wood <phillip.wood123@gmail.com> wrote:
It would have been helpful to retain a bit more context here, I've
restored it so anyone reading this could see the patch that I was
referring to.
>>> diff --git a/f b/f
>>>
>>> new file mode 100644
>>> index 0000000..d00491f
>>> --- /dev/null
>>> +++ b/f
>>> @@ -0,0 +1 @@
>>> +1
>> To me this looks like a corrupt patch because we have a blank line after
>> the "diff --git" header followed by valid extended diff headers. Now
>> that we accept this do we respect the file mode?
>
> No, it does not respect the file mode. "new file mode 100755" is
> ignored and the file gets the default mode.
So that is a good reason to reject this, rather than silently applying a
corrupt patch.
>>> diff --git a/f b/f
>>> diff --git a/g b/g
>> This is the only one that I think it is reasonable to accept - we have
>> an empty patch for "f" followed by a valid patch for "g"
>
> Alright, I will keep accepting this one.
Do we accept that now, or only with your patch?
> For the next version, I plan to die with an error when a "diff --git"
> line has no header lines after it, and a "---" and "+++" patch follows
> before the next "diff --git" line. The error would name the line of
> the "diff --git". An empty section followed by another "diff --git"
> line would still be ignored.
>
> One thing I would like to check with you. On master, a blank line
> after "diff --git" is accepted in a patch that modifies a file. If
> that patch has "old mode" and "new mode" lines, the mode change is
> lost. The rule above would reject these patches too. What is your view
> on this?
Oh, so
diff --git a/f b/f
index 573541a..d00491f 100644
--- a/f
+++ b/f
@@ -1 +1 @@
-0
+1
applies. That looks like a corrupt patch as well to me and if we're
ignoring the mode headers I'd say it is definitely a bug and rejecting
it is the right thing to do.
Thanks
Phillip
next prev parent reply other threads:[~2026-11-09 14:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-17 15:17 Git crashed on `git apply --check` Gingrspacecadet
2026-10-24 6:10 ` Tanga Joris
[not found] ` <CALdwsC11JHUBBTt3e_RFixLYSF0VU1C+mG7bQsO0vV=a68XHNw@mail.gmail.com>
2026-10-25 22:56 ` Tanga Joris
2026-11-07 19:54 ` [Outreachy PATCH 1/2] apply: do not keep names from an unused "diff --git" line Tanga Joris
2026-11-07 19:54 ` [Outreachy PATCH 2/2] apply: reject new and deleted files that have both names Tanga Joris
2026-11-09 10:52 ` [Outreachy PATCH 1/2] apply: do not keep names from an unused "diff --git" line Phillip Wood
2026-11-09 13:13 ` Tanga Joris
2026-11-09 14:31 ` Phillip Wood [this message]
2026-11-09 20:54 ` Tanga Joris
2026-11-09 21:06 ` Junio C Hamano
2026-11-09 23:03 ` Tanga Joris
2026-11-09 19:56 ` Junio C Hamano
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=d5bb8fe0-7706-4e3d-b471-ad004411a9ed@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jackrawlings2011@gmail.com \
--cc=kaartic.sivaraam@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=siddharthasthana31@gmail.com \
--cc=tangajoris@gmail.com \
--cc=usmanakinyemi202@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