From: Eric Wong <e@80x24.org>
To: Jerry Zhang <jerry@skydio.com>
Cc: git@vger.kernel.org, gitster@pobox.com, ross@skydio.com,
abe@skydio.com, brian.kubisiak@skydio.com
Subject: Re: [PATCH] git-apply: allow empty patch text
Date: Tue, 27 Apr 2021 05:46:32 +0000 [thread overview]
Message-ID: <20210427054632.GA31347@dcvr> (raw)
In-Reply-To: <20210427011246.28054-1-jerry@skydio.com>
Jerry Zhang <jerry@skydio.com> wrote:
> "git diff" produces no patch text if
> there is no diff, but "git apply" exits
> with code 128 if the patch text is empty.
>
> Since every valid "git diff" should
> result in a successful patch application
> when applied to the same preimage as
> the diff,
Should it result in successful patch application? (Why?)
I fear this change can cause errors in pipelines to go
undetected (since "set -o pipefail" is not POSIX).
In my experience, zero-byte files is also a common failure mode
for some filesystems, even after fsck marked them as clean.
Perhaps guarding this behavior with --allow-empty (as commit and
cherry-pick do) is safer.
> diff --git a/t/t4126-apply-empty.sh b/t/t4126-apply-empty.sh
> index ceb6a79fe0..37351be609 100755
> --- a/t/t4126-apply-empty.sh
> +++ b/t/t4126-apply-empty.sh
> @@ -31,6 +31,13 @@ test_expect_success 'apply empty' '
> test_cmp expect empty
> '
>
> +test_expect_success 'apply empty diff' '
> + git reset --hard &&
> + git diff >empty.patch &&
> + git apply empty.patch &&
> + git diff | git apply -
> +'
It shouldn't be necessary to use "git diff" to generate empty
output. Tests are too slow for me on Linux, even. Something
like:
>empty.patch &&
git apply empty.patch &&
git apply - <empty.patch
...ought to be realistic enough, but /dev/null in place of
empty.patch is probably portable enough, too. Thanks.
next prev parent reply other threads:[~2021-04-27 5:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 1:12 [PATCH] git-apply: allow empty patch text Jerry Zhang
2021-04-27 5:46 ` Eric Wong [this message]
2021-04-27 6:28 ` Junio C Hamano
2021-04-27 19:40 ` [PATCH V2] git-apply: add --allow-empty flag Jerry Zhang
2021-04-28 5:08 ` Junio C Hamano
2021-04-28 18:40 ` Jerry Zhang
2021-04-29 0:32 ` Ævar Arnfjörð Bjarmason
2021-12-11 3:13 ` [PATCH V3] " Jerry Zhang
2021-12-11 7:36 ` Bagas Sanjaya
2021-12-13 20:28 ` [PATCH V4] " Jerry Zhang
2021-12-13 21:44 ` Junio C Hamano
2021-12-13 21:52 ` Jerry Zhang
2021-12-13 21:57 ` 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=20210427054632.GA31347@dcvr \
--to=e@80x24.org \
--cc=abe@skydio.com \
--cc=brian.kubisiak@skydio.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jerry@skydio.com \
--cc=ross@skydio.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.
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).