]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-recursive.c: tolerate missing files while refreshing index
authorBrad King <brad.king@kitware.com>
Mon, 27 Jan 2014 14:45:09 +0000 (09:45 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Feb 2014 22:31:30 +0000 (14:31 -0800)
Teach add_cacheinfo to tell make_cache_entry to skip refreshing stat
information when a file is missing from the work tree.  We do not want
the index to be stat-dirty after the merge but also do not want to fail
when a file happens to be missing.

This fixes the 'merge-recursive w/ empty work tree - ours has rename'
case in t3030-merge-recursive.

Suggested-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Brad King <brad.king@kitware.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c
t/t3030-merge-recursive.sh

index 05311e411ce85e25840dbf92404b3b0fd4831c75..786dee7596d54d727e1fa7886de03136cccd4155 100644 (file)
@@ -202,7 +202,8 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
 {
        struct cache_entry *ce;
        ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage,
-                             (refresh ? CE_MATCH_REFRESH : 0 ));
+                             (refresh ? (CE_MATCH_REFRESH |
+                                         CE_MATCH_IGNORE_MISSING) : 0 ));
        if (!ce)
                return error(_("addinfo_cache failed for path '%s'"), path);
        return add_cache_entry(ce, options);
index 3db3bf66517919eb3374668581906c730cc20803..82e18548c39817dec496766d2c8d500668fc4f76 100755 (executable)
@@ -518,7 +518,7 @@ test_expect_success 'reset and bind merge' '
 
 '
 
-test_expect_failure 'merge-recursive w/ empty work tree - ours has rename' '
+test_expect_success 'merge-recursive w/ empty work tree - ours has rename' '
        (
                GIT_WORK_TREE="$PWD/ours-has-rename-work" &&
                export GIT_WORK_TREE &&