]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-recursive: avoid triggering add_cacheinfo error with dirty mod
authorElijah Newren <newren@gmail.com>
Thu, 19 Apr 2018 17:58:18 +0000 (10:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 May 2018 07:11:00 +0000 (16:11 +0900)
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>
merge-recursive.c
t/t3501-revert-cherry-pick.sh

index bffcd5fa514d6555c0ff927bc0d5c47198d3f8de..804dfefd15d5800629f12146cbd7264b722c2169 100644 (file)
@@ -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;
                }
index 3871807d099815a75e86242bb111f68a4957518c..d1c68af8c50e75255baa618ea297549b548c0fc2 100755 (executable)
@@ -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 &&