From: Elijah Newren Date: Thu, 19 Apr 2018 17:58:18 +0000 (-0700) Subject: merge-recursive: avoid triggering add_cacheinfo error with dirty mod X-Git-Tag: v2.18.0-rc0~50^2~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2f682e21a6dc3b7403fd0162252183fdef019274?ds=inline;hp=--cc 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 Signed-off-by: Junio C Hamano --- 2f682e21a6dc3b7403fd0162252183fdef019274 diff --git a/merge-recursive.c b/merge-recursive.c index bffcd5fa51..804dfefd15 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -2786,7 +2786,7 @@ static int merge_content(struct merge_options *o, path_renamed_outside_HEAD = !path2 || !strcmp(path, path2); if (!path_renamed_outside_HEAD) { if (add_cacheinfo(o, mfi.mode, &mfi.oid, path, - 0, (!o->call_depth), 0)) + 0, (!o->call_depth && !is_dirty), 0)) return -1; return mfi.clean; } diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index 3871807d09..d1c68af8c5 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -141,7 +141,7 @@ test_expect_success 'cherry-pick "-" works with arguments' ' test_cmp expect actual ' -test_expect_failure 'cherry-pick works with dirty renamed file' ' +test_expect_success 'cherry-pick works with dirty renamed file' ' test_commit to-rename && git checkout -b unrelated && test_commit unrelated &&