Skip to content

Commit 49ff3cb

Browse files
vdyegitster
authored andcommitted
checkout: fix nested sparse directory diff in sparse index
Add the 'recursive' diff flag to the local changes reporting done by 'git checkout' in 'show_local_changes()'. Without the flag enabled, unexpanded sparse directories will not be recursed into to report the diff of each file's contents, resulting in the reported local changes including "modified" sparse directories. The same issue was found and fixed for 'git status' in 2c521b0 (status: fix nested sparse directory diff in sparse index, 2022-03-01) Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 00d1260 commit 49ff3cb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

builtin/checkout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ static void show_local_changes(struct object *head,
626626
repo_init_revisions(the_repository, &rev, NULL);
627627
rev.diffopt.flags = opts->flags;
628628
rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
629+
rev.diffopt.flags.recursive = 1;
629630
diff_setup_done(&rev.diffopt);
630631
add_pending_object(&rev, head, NULL);
631632
run_diff_index(&rev, 0);

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,14 @@ test_expect_success 'deep changes during checkout' '
372372
test_all_match git checkout base
373373
'
374374

375+
test_expect_success 'checkout with modified sparse directory' '
376+
init_repos &&
377+
378+
test_all_match git checkout rename-in-to-out -- . &&
379+
test_sparse_match git sparse-checkout reapply &&
380+
test_all_match git checkout base
381+
'
382+
375383
test_expect_success 'add outside sparse cone' '
376384
init_repos &&
377385

0 commit comments

Comments
 (0)