From: Junio C Hamano <gitster@pobox.com>
To: Adam Williamson <awilliam@redhat.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 14:09:43 -0700 [thread overview]
Message-ID: <xmqq5yw1ywdk.fsf@gitster.g> (raw)
In-Reply-To: <02be6a48411fa100e7d1292fc312f7fcf571f334.camel@redhat.com> (Adam Williamson's message of "Tue, 17 Aug 2021 11:50:42 -0700")
Adam Williamson <awilliam@redhat.com> writes:
> Hi folks! So I ran into an odd issue with git today. I'm kinda
> surprised I can't find any prior discussion of it, but oh well. The
> situation is this: I ran git format-patch on a commit that adds three
> empty files to a repository - this commit:
> https://github.com/mesonbuild/meson/commit/5c87167a34c6ed703444af180fffd8a45a7928ee
> the relevant lines from the patch file it produced look like this:
>
> ===
>
> diff --git a/test cases/common/56 array methods/a.txt b/test cases/common/56 array methods/a.txt
> new file mode 100644
> index 000000000..e69de29bb
> diff --git a/test cases/common/56 array methods/b.txt b/test cases/common/56 array methods/b.txt
> new file mode 100644
> index 000000000..e69de29bb
> diff --git a/test cases/common/56 array methods/c.txt b/test cases/common/56 array methods/c.txt
> new file mode 100644
> index 000000000..e69de29bb
I do not have very ancient build of Git handy, but I know Git as old
as v1.3.0 (which I consider is one of the two versions of historical
importance, the other being v1.5.3) behaved this way and we haven't
changed it ever since, so I am surprised too to learn that "GNU
patch" cannot grok it. Even though you didn't mention it, am I
correct to assume that "patch" has a similar issue with a change
that removes an empty file?
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.
Thanks.
next prev parent reply other threads:[~2021-08-19 21:09 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 [this message]
2021-08-19 21:25 ` Adam Williamson
2021-08-20 6:15 ` Gwyneth Morgan
2021-08-20 6:46 ` Adam Williamson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq5yw1ywdk.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=awilliam@redhat.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.