author | Junio C Hamano <gitster@pobox.com> | |
Wed, 21 Dec 2011 19:42:45 +0000 (11:42 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 21 Dec 2011 19:42:45 +0000 (11:42 -0800) |
* 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
builtin/apply.c: report error on failure to recognize input
t/t4131-apply-fake-ancestor.sh: fix broken test
builtin/apply.c | patch | blob | history | |
t/t4131-apply-fake-ancestor.sh | patch | blob | history | |
t/t4136-apply-check.sh | [new file with mode: 0755] | patch | blob |
diff --git a/builtin/apply.c b/builtin/apply.c
index b3b59db534ff0763c822ae9da571d5643a8b709a..c24dc546d0cc3f223c40c12aa20dc75eff13d4f9 100644 (file)
--- a/builtin/apply.c
+++ b/builtin/apply.c
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) {
offset += nr;
}
+ if (!list && !skipped_patch)
+ die("unrecognized input");
+
if (whitespace_error && (ws_error_action == die_on_ws_error))
apply = 0;
!apply_with_reject)
exit(1);
- if (apply && write_out_results(list, skipped_patch))
+ if (apply && write_out_results(list))
exit(1);
if (fake_ancestor)
index 94373ca9a0c20a4465a8788eef3dd7596f6e6c2d..b1361ce54693a07486f5837b0fe477f828b80a4e 100755 (executable)
test_commit 1 &&
test_commit 2 &&
mkdir sub &&
- test_commit 3 sub/3 &&
+ test_commit 3 sub/3.t &&
test_commit 4
'
diff --git a/t/t4136-apply-check.sh b/t/t4136-apply-check.sh
--- /dev/null
+++ b/t/t4136-apply-check.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+test_description='git apply should exit non-zero with unrecognized input.'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_commit 1
+'
+
+test_expect_success 'apply --check exits non-zero with unrecognized input' '
+ test_must_fail git apply --check - <<-\EOF
+ I am not a patch
+ I look nothing like a patch
+ git apply must fail
+ EOF
+'
+
+test_done