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 2c521b0e49 (status: fix nested sparse directory diff in sparse index, 2022-03-01) Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Victoria Dye committed Aug 8, 2022 at 19:07 UTC 49ff3cb90fee9d0591b59a4c40ac2330163cab87
2 files changed +9
builtin/checkout.c
+1
@@ -626,6 +626,7 @@ static void show_local_changes(struct object *head,
626 repo_init_revisions(the_repository, &rev, NULL);
627 rev.diffopt.flags = opts->flags;
628 rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
629 + rev.diffopt.flags.recursive = 1;
630 diff_setup_done(&rev.diffopt);
631 add_pending_object(&rev, head, NULL);
632 run_diff_index(&rev, 0);
t/t1092-sparse-checkout-compatibility.sh
+8
@@ -372,6 +372,14 @@ test_expect_success 'deep changes during checkout' '
372 test_all_match git checkout base
373 '
374
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 +
383 test_expect_success 'add outside sparse cone' '
384 init_repos &&
385