From: Elijah Newren Date: Mon, 27 Sep 2021 16:33:46 +0000 (+0000) Subject: unpack-trees: avoid nuking untracked dir in way of locally deleted file X-Git-Tag: v2.34.0-rc0~63^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=56d06fe4aa9089bccb4ff247fc3224fc7431c72d;p=thirdparty%2Fgit.git unpack-trees: avoid nuking untracked dir in way of locally deleted file Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- diff --git a/t/t2500-untracked-overwriting.sh b/t/t2500-untracked-overwriting.sh index 5ec66058cf..5c0bf4d21f 100755 --- a/t/t2500-untracked-overwriting.sh +++ b/t/t2500-untracked-overwriting.sh @@ -218,7 +218,7 @@ test_expect_success 'git am --abort and untracked dir vs. unmerged file' ' ) ' -test_expect_failure 'git am --skip and untracked dir vs deleted file' ' +test_expect_success 'git am --skip and untracked dir vs deleted file' ' test_setup_sequencing am_skip_and_untracked && ( cd sequencing_am_skip_and_untracked && diff --git a/unpack-trees.c b/unpack-trees.c index 821f532c85..48ca93a725 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -2409,7 +2409,10 @@ static int deleted_entry(const struct cache_entry *ce, if (verify_absent(ce, ERROR_WOULD_LOSE_UNTRACKED_REMOVED, o)) return -1; return 0; + } else if (verify_absent_if_directory(ce, ERROR_WOULD_LOSE_UNTRACKED_REMOVED, o)) { + return -1; } + if (!(old->ce_flags & CE_CONFLICTED) && verify_uptodate(old, o)) return -1; add_entry(o, ce, CE_REMOVE, 0);