[PATCH v2 3/3] merge-recursive.c: Tolerate missing files while refreshing index
- From
Brad King <brad.king@kitware.com>
- Date
- Jan 24, 2014, 20:10 UTC
- Message-ID
- <92b0b0310b762276db23161d34ba94a86fd67139.1390592626.git.brad.king@kitware.com>
- In-Reply-To
- <cover.1390592626.git.brad.king@kitware.com>
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> --- merge-recursive.c | 3 ++- t/t3030-merge-recursive.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/merge-recursive.c b/merge-recursive.c index a6fe7f9..35935c5 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -201,7 +201,8 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh, int options) { struct cache_entry *ce; - ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage, refresh, 0); + ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage, + refresh, REFRESH_IGNORE_MISSING); if (!ce) return error(_("addinfo_cache failed for path '%s'"), path); return add_cache_entry(ce, options); diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index 3db3bf6..82e1854 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -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 &&
-- 1.8.5.2