]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-recursive: ensure we write updates for directory-renamed file
authorElijah Newren <newren@gmail.com>
Wed, 14 Feb 2018 18:52:06 +0000 (10:52 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Feb 2018 22:11:58 +0000 (14:11 -0800)
When a file is present in HEAD before the merge and the other side of the
merge does not modify that file, we try to avoid re-writing the file and
making it stat-dirty.  However, when a file is present in HEAD before the
merge and was in a directory that was renamed by the other side of the
merge, we have to move the file to a new location and re-write it.
Update the code that checks whether we can skip the update to also work in
the presence of directory renames.

Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c
t/t6043-merge-rename-directories.sh

index 4a1ecdea03cb0e3c5cf0b9a524abdff47279a239..5f42c677d52bc3ea3ac56efda0fae6cd6d2c4a63 100644 (file)
@@ -2763,7 +2763,6 @@ static int merge_content(struct merge_options *o,
 
        if (mfi.clean && !df_conflict_remains &&
            oid_eq(&mfi.oid, a_oid) && mfi.mode == a_mode) {
-               int path_renamed_outside_HEAD;
                output(o, 3, _("Skipped %s (merged same as existing)"), path);
                /*
                 * The content merge resulted in the same file contents we
@@ -2771,8 +2770,7 @@ static int merge_content(struct merge_options *o,
                 * are recorded at the correct path (which may not be true
                 * if the merge involves a rename).
                 */
-               path_renamed_outside_HEAD = !path2 || !strcmp(path, path2);
-               if (!path_renamed_outside_HEAD) {
+               if (was_tracked(path)) {
                        add_cacheinfo(o, mfi.mode, &mfi.oid, path,
                                      0, (!o->call_depth), 0);
                        return mfi.clean;
index 45f620633f92d2d4a96332502e6e2d3e4af7ffce..2e28f2908d5571715aeddaa0962bb8adf4e14591 100755 (executable)
@@ -3884,7 +3884,7 @@ test_expect_success '12b-setup: Moving one directory hierarchy into another' '
        )
 '
 
-test_expect_failure '12b-check: Moving one directory hierarchy into another' '
+test_expect_success '12b-check: Moving one directory hierarchy into another' '
        (
                cd 12b &&