git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Adam Williamson <awilliam@redhat.com>
To: Gwyneth Morgan <gwymor@tilde.club>, Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: git format-patch produces invalid patch if the commit adds an empty file?
Date: Thu, 19 Aug 2021 23:46:34 -0700	[thread overview]
Message-ID: <2119ea2a7b8cd3cb3a84d69b9a9f4471f645667d.camel@redhat.com> (raw)
In-Reply-To: <YR9Iaj/FqAyCMade@tilde.club>

On Fri, 2021-08-20 at 06:15 +0000, Gwyneth Morgan wrote:
> On 2021-08-19 14:09:43-0700, Junio C Hamano wrote:
> > I do not think our patch injestion machinery in "git apply" minds if
> > we added the "--- /dev/null" + "+++ b/<path>" headers (and the
> > reverse for removal of an empty file) to the current output, and I
> > am not fundamentally opposed to such a change.
> > 
> > But because it is such a rare event (and a discouraged practice) to
> > record a completely empty file, I wouldn't place a high priority on
> > doing so myself.
> 
> GNU patch chokes in this case with an unquoted filename with spaces.
> However if we output
> 
> 	diff --git "a/test cases/common/56 array methods/a.txt" "b/test cases/common/56 array methods/a.txt"
> 
> instead of
> 
> 	diff --git a/test cases/common/56 array methods/a.txt b/test cases/common/56 array methods/a.txt
> 
> GNU patch (and Git) will read it correctly. Rather than adding the "---"
> "+++" lines, could we instead quote filenames in the "diff --git" line
> when they contain spaces?

Aha, I did actually wonder about that, because even with the added
lines, the patches don't apply (via `patch`) on Fedora 33 and 34 (and
the error message after adding the lines does seem to indicate the
spaces in the filenames as the culprit). They only apply on Fedora 35
and 36. I hadn't thought to just add quote marks, though of course it
seems obvious now. So yeah, that seems likely to be the best fix. I'll
try and confirm your results tomorrow. Thanks!
-- 
Adam Williamson
Fedora QA
IRC: adamw | Twitter: adamw_ha
https://www.happyassassin.net



  reply	other threads:[~2021-08-20  6:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 18:50 git format-patch produces invalid patch if the commit adds an empty file? Adam Williamson
2021-08-19 21:09 ` Junio C Hamano
2021-08-19 21:25   ` Adam Williamson
2021-08-20  6:15   ` Gwyneth Morgan
2021-08-20  6:46     ` Adam Williamson [this message]
2021-08-20 21:09     ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2119ea2a7b8cd3cb3a84d69b9a9f4471f645667d.camel@redhat.com \
    --to=awilliam@redhat.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=gwymor@tilde.club \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).