]> git.ipfire.org Git - thirdparty/git.git/commitdiff
checkout: ensure full index
authorDerrick Stolee <dstolee@microsoft.com>
Thu, 1 Apr 2021 01:49:44 +0000 (01:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Apr 2021 20:47:03 +0000 (13:47 -0700)
Before iterating over all cache entries in the checkout builtin, ensure
that we have a full index to avoid any unexpected behavior.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c

index 0e6639052001558241645865ffc9b6791a93d8bc..d0dbe63ea119c13076c88cdff35dd6ceb517d8d3 100644 (file)
@@ -368,6 +368,9 @@ static int checkout_worktree(const struct checkout_opts *opts,
                               NULL);
 
        enable_delayed_checkout(&state);
+
+       /* TODO: audit for interaction with sparse-index. */
+       ensure_full_index(&the_index);
        for (pos = 0; pos < active_nr; pos++) {
                struct cache_entry *ce = active_cache[pos];
                if (ce->ce_flags & CE_MATCHED) {
@@ -512,6 +515,8 @@ static int checkout_paths(const struct checkout_opts *opts,
         * Make sure all pathspecs participated in locating the paths
         * to be checked out.
         */
+       /* TODO: audit for interaction with sparse-index. */
+       ensure_full_index(&the_index);
        for (pos = 0; pos < active_nr; pos++)
                if (opts->overlay_mode)
                        mark_ce_for_checkout_overlay(active_cache[pos],