From: Junio C Hamano Date: Wed, 28 Apr 2021 05:08:06 GMT Subject: Re: [PATCH V2] git-apply: add --allow-empty flag Message-ID: In-Reply-To: <20210427194049.14399-1-jerry@skydio.com> Jerry Zhang writes: > Some users or scripts will pipe "git diff" > output to "git apply" when replaying diffs > or commits. In these cases, they will rely > on the return value of "git apply" to know > whether the diff was applied successfully. > > However, for empty commits, "git apply" will > fail. This complicates scripts since they > have to either buffer the diff and check > its length, or run diff again with "exit-code", > essentially doing the diff twice. > > Add the "--allow-empty" flag to "git apply" > which allows it to handle both empty diffs > and empty commits created by "git format-patch > --always" by doing nothing and returning 0. > > Add tests for both with and without --allow-empty. > > Signed-off-by: Jerry Zhang > --- > This patch applies on top of "git-apply: add --quiet flag". > The conflict is in Documentation -> Synopsis and is > trivial to solve. > V1 -> V2: > - Moved behavior under a flag > - Added tests for both cases When people add a flag (a boolean option), it becomes tempting to add a corresponding configuration variable. I wonder it this step should start calling git apply --no-allow-empty when "git am" drives it, so that a futre end-user configuration variable would not break it?