Skip to content

Commit

Permalink
merge-recursive.c: tolerate missing files while refreshing index
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Brad King authored and Junio C Hamano committed Feb 24, 2014
1 parent 2576272 commit 6e2068a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion t/t3030-merge-recursive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 6e2068a

Please sign in to comment.