From: Junio C Hamano Date: Wed, 14 Dec 2011 06:56:22 +0000 (-0800) Subject: Merge branch 'bc/maint-apply-check-no-patch' X-Git-Tag: v1.7.9-rc0~67 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b661a4bc1e172a9c67bf62bdc2715bd4efbc16e5?ds=inline;hp=-c Merge branch 'bc/maint-apply-check-no-patch' * bc/maint-apply-check-no-patch: builtin/apply.c: report error on failure to recognize input t/t4131-apply-fake-ancestor.sh: fix broken test --- b661a4bc1e172a9c67bf62bdc2715bd4efbc16e5 diff --combined builtin/apply.c index b3b59db534,a39782d1c5..c24dc546d0 --- a/builtin/apply.c +++ b/builtin/apply.c @@@ -250,6 -250,9 +250,6 @@@ static int fuzzy_matchlines(const char const char *last2 = s2 + n2 - 1; int result = 0; - if (n1 < 0 || n2 < 0) - return 0; - /* ignore line endings */ while ((*last1 == '\r') || (*last1 == '\n')) last1--; @@@ -3587,15 -3590,12 +3587,12 @@@ static int write_out_one_reject(struct 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) { @@@ -3721,6 -3721,9 +3718,9 @@@ static int apply_patch(int fd, const ch offset += nr; } + if (!list && !skipped_patch) + die("unrecognized input"); + if (whitespace_error && (ws_error_action == die_on_ws_error)) apply = 0; @@@ -3738,7 -3741,7 +3738,7 @@@ !apply_with_reject) exit(1); - if (apply && write_out_results(list, skipped_patch)) + if (apply && write_out_results(list)) exit(1); if (fake_ancestor) @@@ -3838,6 -3841,7 +3838,6 @@@ int cmd_apply(int argc, const char **ar int i; int errs = 0; int is_not_gitdir = !startup_info->have_repository; - int binary; int force_apply = 0; const char *whitespace_option = NULL; @@@ -3856,8 -3860,12 +3856,8 @@@ "ignore additions made by the patch"), OPT_BOOLEAN(0, "stat", &diffstat, "instead of applying the patch, output diffstat for the input"), - { OPTION_BOOLEAN, 0, "allow-binary-replacement", &binary, - NULL, "old option, now no-op", - PARSE_OPT_HIDDEN | PARSE_OPT_NOARG }, - { OPTION_BOOLEAN, 0, "binary", &binary, - NULL, "old option, now no-op", - PARSE_OPT_HIDDEN | PARSE_OPT_NOARG }, + OPT_NOOP_NOARG(0, "allow-binary-replacement"), + OPT_NOOP_NOARG(0, "binary"), OPT_BOOLEAN(0, "numstat", &numstat, "shows number of added and deleted lines in decimal notation"), OPT_BOOLEAN(0, "summary", &summary,