summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--add-patch.c3
-rwxr-xr-xt/t3701-add-interactive.sh10
2 files changed, 12 insertions, 1 deletions
diff --git a/add-patch.c b/add-patch.c
index 302e6ba7d9..61f42de9ea 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -956,6 +956,7 @@ static int split_hunk(struct add_p_state *s, struct file_diff *file_diff,
* sizeof(*hunk));
hunk = file_diff->hunk + hunk_index;
hunk->splittable_into = 1;
+ hunk->use = UNDECIDED_HUNK;
memset(hunk + 1, 0, (splittable_into - 1) * sizeof(*hunk));
header = &hunk->header;
@@ -1057,7 +1058,7 @@ next_hunk_line:
hunk++;
hunk->splittable_into = 1;
- hunk->use = hunk[-1].use;
+ hunk->use = UNDECIDED_HUNK;
header = &hunk->header;
header->old_count = header->new_count = context_line_count;
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 04d2a19835..a6829fd085 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -1301,4 +1301,14 @@ do
'
done
+test_expect_success 'splitting previous hunk marks split hunks as undecided' '
+ test_write_lines a " " b c d e f g h i j k >file &&
+ git add file &&
+ test_write_lines x " " b y d e f g h i j x >file &&
+ test_write_lines n K s n y q | git add -p file &&
+ git cat-file blob :file >actual &&
+ test_write_lines a " " b y d e f g h i j k >expect &&
+ test_cmp expect actual
+'
+
test_done