Skip to content

Commit fe3939b

Browse files
committed
Merge branch 'vd/sparse-reset-checkout-fixes'
Segfault fix-up to an earlier fix to the topic to teach "git reset" and "git checkout" work better in a sparse checkout. * vd/sparse-reset-checkout-fixes: unpack-trees: fix sparse directory recursion check
2 parents fd1ec82 + 037f8ea commit fe3939b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,15 @@ test_expect_success 'checkout with modified sparse directory' '
380380
test_all_match git checkout base
381381
'
382382

383+
test_expect_success 'checkout orphan then non-orphan' '
384+
init_repos &&
385+
386+
test_all_match git checkout --orphan test-orphan &&
387+
test_all_match git status --porcelain=v2 &&
388+
test_all_match git checkout base &&
389+
test_all_match git status --porcelain=v2
390+
'
391+
383392
test_expect_success 'add outside sparse cone' '
384393
init_repos &&
385394

unpack-trees.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ static void debug_unpack_callback(int n,
14231423
* from the tree walk at the given traverse_info.
14241424
*/
14251425
static int is_sparse_directory_entry(struct cache_entry *ce,
1426-
struct name_entry *name,
1426+
const struct name_entry *name,
14271427
struct traverse_info *info)
14281428
{
14291429
if (!ce || !name || !S_ISSPARSEDIR(ce->ce_mode))
@@ -1562,7 +1562,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
15621562
}
15631563
}
15641564

1565-
if (!is_sparse_directory_entry(src[0], names, info) &&
1565+
if (!is_sparse_directory_entry(src[0], p, info) &&
15661566
!is_new_sparse_dir &&
15671567
traverse_trees_recursive(n, dirmask, mask & ~dirmask,
15681568
names, info) < 0) {

0 commit comments

Comments
 (0)