Skip to content

Commit 406cc9b

Browse files
committed
Merge branch 'bc/maint-apply-check-no-patch' into maint
* 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
2 parents 3bb8d69 + cc64b31 commit 406cc9b

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

builtin/apply.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3587,15 +3587,12 @@ static int write_out_one_reject(struct patch *patch)
35873587
return -1;
35883588
}
35893589

3590-
static int write_out_results(struct patch *list, int skipped_patch)
3590+
static int write_out_results(struct patch *list)
35913591
{
35923592
int phase;
35933593
int errs = 0;
35943594
struct patch *l;
35953595

3596-
if (!list && !skipped_patch)
3597-
return error("No changes");
3598-
35993596
for (phase = 0; phase < 2; phase++) {
36003597
l = list;
36013598
while (l) {
@@ -3721,6 +3718,9 @@ static int apply_patch(int fd, const char *filename, int options)
37213718
offset += nr;
37223719
}
37233720

3721+
if (!list && !skipped_patch)
3722+
die("unrecognized input");
3723+
37243724
if (whitespace_error && (ws_error_action == die_on_ws_error))
37253725
apply = 0;
37263726

@@ -3738,7 +3738,7 @@ static int apply_patch(int fd, const char *filename, int options)
37383738
!apply_with_reject)
37393739
exit(1);
37403740

3741-
if (apply && write_out_results(list, skipped_patch))
3741+
if (apply && write_out_results(list))
37423742
exit(1);
37433743

37443744
if (fake_ancestor)

t/t4131-apply-fake-ancestor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test_expect_success 'setup' '
1111
test_commit 1 &&
1212
test_commit 2 &&
1313
mkdir sub &&
14-
test_commit 3 sub/3 &&
14+
test_commit 3 sub/3.t &&
1515
test_commit 4
1616
'
1717

t/t4136-apply-check.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
test_description='git apply should exit non-zero with unrecognized input.'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success 'setup' '
8+
test_commit 1
9+
'
10+
11+
test_expect_success 'apply --check exits non-zero with unrecognized input' '
12+
test_must_fail git apply --check - <<-\EOF
13+
I am not a patch
14+
I look nothing like a patch
15+
git apply must fail
16+
EOF
17+
'
18+
19+
test_done

0 commit comments

Comments
 (0)