Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Zhang <jerry@skydio.com>2021-12-14 01:03:27 +0300
committerJunio C Hamano <gitster@pobox.com>2021-12-14 01:30:25 +0300
commit324eb77ee76277be99bdc54ef0b74ff30f5f567b (patch)
treed9eecb504b5d4c671fe2cde24a7110b53de5b632 /apply.h
parentc21b8ae857d0d58b67ca77384ccc1880d834c2d5 (diff)
git-apply: add --allow-empty flag
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 <jerry@skydio.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'apply.h')
-rw-r--r--apply.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/apply.h b/apply.h
index da3d95fa50..16202da160 100644
--- a/apply.h
+++ b/apply.h
@@ -66,6 +66,7 @@ struct apply_state {
int threeway;
int unidiff_zero;
int unsafe_paths;
+ int allow_empty;
/* Other non boolean parameters */
struct repository *repo;