Skip to content

Commit bda53f4

Browse files
committed
Merge branch 'js/apply-recount-allow-noop'
When editing a patch in a "git add -i" session, a hunk could be made to no-op. The "git apply" program used to reject a patch with such a no-op hunk to catch user mistakes, but it is now updated to explicitly allow a no-op hunk in an edited patch. * js/apply-recount-allow-noop: apply --recount: allow "no-op hunks"
2 parents c72431f + 22cb383 commit bda53f4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

apply.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ static int parse_fragment(struct apply_state *state,
17481748
}
17491749
if (oldlines || newlines)
17501750
return -1;
1751-
if (!deleted && !added)
1751+
if (!patch->recount && !deleted && !added)
17521752
return -1;
17531753

17541754
fragment->leading = leading;

t/t4136-apply-check.sh

+12
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ test_expect_success 'apply exits non-zero with no-op patch' '
2929
test_must_fail git apply --check input
3030
'
3131

32+
test_expect_success '`apply --recount` allows no-op patch' '
33+
echo 1 >1 &&
34+
git apply --recount --check <<-\EOF
35+
diff --get a/1 b/1
36+
index 6696ea4..606eddd 100644
37+
--- a/1
38+
+++ b/1
39+
@@ -1,1 +1,1 @@
40+
1
41+
EOF
42+
'
43+
3244
test_expect_success 'invalid combination: create and copy' '
3345
test_must_fail git apply --check - <<-\EOF
3446
diff --git a/1 b/2

0 commit comments

Comments
 (0)