summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2021-09-24 06:37:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-09-24 16:24:25 (GMT)
commitcea16eea0b85789d7edd4967a96d36f6feabf7a9 (patch)
treee611e2a03886dcaa531f6d35afb0e17bc503f0e0
parent6b657a4c4c6dbb250982c9c31219426437f2ca35 (diff)
downloadgit-cea16eea0b85789d7edd4967a96d36f6feabf7a9.zip
git-cea16eea0b85789d7edd4967a96d36f6feabf7a9.tar.gz
git-cea16eea0b85789d7edd4967a96d36f6feabf7a9.tar.bz2
unpack-trees: avoid nuking untracked dir in way of locally deleted file
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/t2500-untracked-overwriting.sh2
-rw-r--r--unpack-trees.c3
2 files changed, 4 insertions, 1 deletions
diff --git a/t/t2500-untracked-overwriting.sh b/t/t2500-untracked-overwriting.sh
index 5ec6605..5c0bf4d 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 788a092..495555c 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -2392,7 +2392,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);