summaryrefslogtreecommitdiff
path: root/builtin/apply.c
diff options
context:
space:
mode:
authorBrandon Casey <drafnel@gmail.com>2011-12-03 20:35:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-12-05 19:20:50 (GMT)
commitcc64b318f26c9e176c4f07b1a459a86e7a04c4eb (patch)
tree7199e2205d9d1ec141595731eec3a9c2388b3df1 /builtin/apply.c
parent590a472b363ba9d6e75b1dbf07f20e80ae9a587d (diff)
downloadgit-cc64b318f26c9e176c4f07b1a459a86e7a04c4eb.zip
git-cc64b318f26c9e176c4f07b1a459a86e7a04c4eb.tar.gz
git-cc64b318f26c9e176c4f07b1a459a86e7a04c4eb.tar.bz2
builtin/apply.c: report error on failure to recognize input
When git apply is passed something that is not a patch, it does not produce an error message or exit with a non-zero status if it was not actually "applying" the patch i.e. --check or --numstat etc were supplied on the command line. Fix this by producing an error when apply fails to find any hunks whatsoever while parsing the patch. This will cause some of the output formats (--numstat, --diffstat, etc) to produce an error when they formerly would have reported zero changes and exited successfully. That seems like the correct behavior though. Failure to recognize the input as a patch should be an error. Plus, add a test. Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/apply.c')
-rw-r--r--builtin/apply.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index 311a94e..a39782d 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3590,15 +3590,12 @@ static int write_out_one_reject(struct patch *patch)
return -1;
}
-static int write_out_results(struct patch *list, int skipped_patch)
+static int write_out_results(struct patch *list)
{
int phase;
int errs = 0;
struct patch *l;
- if (!list && !skipped_patch)
- return error("No changes");
-
for (phase = 0; phase < 2; phase++) {
l = list;
while (l) {
@@ -3724,6 +3721,9 @@ static int apply_patch(int fd, const char *filename, int options)
offset += nr;
}
+ if (!list && !skipped_patch)
+ die("unrecognized input");
+
if (whitespace_error && (ws_error_action == die_on_ws_error))
apply = 0;
@@ -3741,7 +3741,7 @@ static int apply_patch(int fd, const char *filename, int options)
!apply_with_reject)
exit(1);
- if (apply && write_out_results(list, skipped_patch))
+ if (apply && write_out_results(list))
exit(1);
if (fake_ancestor)