]> git.ipfire.org Git - thirdparty/git.git/commitdiff
checkout: fix nested sparse directory diff in sparse index
authorVictoria Dye <vdye@github.com>
Mon, 8 Aug 2022 19:07:49 +0000 (19:07 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Aug 2022 20:21:49 +0000 (13:21 -0700)
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>
builtin/checkout.c
t/t1092-sparse-checkout-compatibility.sh

index 2eefda81d8cf89f6d5405e1ee218f0c698f4fb78..1144c569c62ea1ebeaa8ec0d0a058496a749fc33 100644 (file)
@@ -626,6 +626,7 @@ static void show_local_changes(struct object *head,
        repo_init_revisions(the_repository, &rev, NULL);
        rev.diffopt.flags = opts->flags;
        rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
+       rev.diffopt.flags.recursive = 1;
        diff_setup_done(&rev.diffopt);
        add_pending_object(&rev, head, NULL);
        run_diff_index(&rev, 0);
index f9f8c988bb4905939824903b3c59620450238350..83458b092c7c5ab32ca88b1ffb3afc5e676f1ed9 100755 (executable)
@@ -372,6 +372,14 @@ test_expect_success 'deep changes during checkout' '
        test_all_match git checkout base
 '
 
+test_expect_success 'checkout with modified sparse directory' '
+       init_repos &&
+
+       test_all_match git checkout rename-in-to-out -- . &&
+       test_sparse_match git sparse-checkout reapply &&
+       test_all_match git checkout base
+'
+
 test_expect_success 'add outside sparse cone' '
        init_repos &&