aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--add-patch.c3
-rwxr-xr-xt/t3701-add-interactive.sh21
2 files changed, 23 insertions, 1 deletions
diff --git a/add-patch.c b/add-patch.c
index a86a92e164..d7fc4f4cd2 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -483,7 +483,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
if (!eol)
eol = pend;
- if (starts_with(p, "diff ")) {
+ if (starts_with(p, "diff ") ||
+ starts_with(p, "* Unmerged path ")) {
complete_file(marker, hunk);
ALLOC_GROW_BY(s->file_diff, s->file_diff_nr, 1,
file_diff_alloc);
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 5841f280fb..d0a2ba739e 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -1068,4 +1068,25 @@ test_expect_success 'show help from add--helper' '
test_cmp expect actual
'
+test_expect_success 'reset -p with unmerged files' '
+ test_when_finished "git checkout --force main" &&
+ test_commit one conflict &&
+ git checkout -B side HEAD^ &&
+ test_commit two conflict &&
+ test_must_fail git merge one &&
+
+ # this is a noop with only an unmerged entry
+ git reset -p &&
+
+ # add files that sort before and after unmerged entry
+ echo a >a &&
+ echo z >z &&
+ git add a z &&
+
+ # confirm that we can reset those files
+ printf "%s\n" y y | git reset -p &&
+ git diff-index --cached --diff-filter=u HEAD >staged &&
+ test_must_be_empty staged
+'
+
test_done