merge-recursive: avoid triggering add_cacheinfo error with dirty mod
If a cherry-pick or merge with a rename results in a skippable update (due to the merged content matching what HEAD already had), but the working directory is dirty, avoid trying to refresh the index as that will fail. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Apr 19, 2018 at 10:58 UTC
2f682e21a6dc3b7403fd0162252183fdef019274
2 files changed
+2
-2
merge-recursive.c
+1
-1
@@ -2786,7 +2786,7 @@ static int merge_content(struct merge_options *o,
2786
path_renamed_outside_HEAD = !path2 || !strcmp(path, path2);
2787
if (!path_renamed_outside_HEAD) {
2788
if (add_cacheinfo(o, mfi.mode, &mfi.oid, path,
2789
- 0, (!o->call_depth), 0))
2789
+ 0, (!o->call_depth && !is_dirty), 0))
2790
return -1;
2791
return mfi.clean;
2792
}
t/t3501-revert-cherry-pick.sh
+1
-1
@@ -141,7 +141,7 @@ test_expect_success 'cherry-pick "-" works with arguments' '
141
test_cmp expect actual
142
'
143
144
-test_expect_failure 'cherry-pick works with dirty renamed file' '
144
+test_expect_success 'cherry-pick works with dirty renamed file' '
145
test_commit to-rename &&
146
git checkout -b unrelated &&
147
test_commit unrelated &&