diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index e17c1e72768b69..ab36c2c3fa9a81 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -381,6 +381,15 @@ test_expect_success 'checkout with modified sparse directory' ' test_all_match git checkout base ' +test_expect_success 'checkout orphan then non-orphan' ' + init_repos && + + test_all_match git checkout --orphan test-orphan && + test_all_match git status --porcelain=v2 && + test_all_match git checkout base && + test_all_match git status --porcelain=v2 +' + test_expect_success 'add outside sparse cone' ' init_repos && diff --git a/unpack-trees.c b/unpack-trees.c index 72f1bc0f3cf987..a5cd67d1bbda16 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1442,7 +1442,7 @@ static void debug_unpack_callback(int n, * from the tree walk at the given traverse_info. */ static int is_sparse_directory_entry(struct cache_entry *ce, - struct name_entry *name, + const struct name_entry *name, struct traverse_info *info) { if (!ce || !name || !S_ISSPARSEDIR(ce->ce_mode)) @@ -1581,7 +1581,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str } } - if (!is_sparse_directory_entry(src[0], names, info) && + if (!is_sparse_directory_entry(src[0], p, info) && !is_new_sparse_dir && traverse_trees_recursive(n, dirmask, mask & ~dirmask, names, info) < 0) {