]> git.ipfire.org Git - thirdparty/git.git/commitdiff
merge-index: ensure full index
authorDerrick Stolee <dstolee@microsoft.com>
Thu, 1 Apr 2021 01:49:50 +0000 (01:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Apr 2021 20:47:21 +0000 (13:47 -0700)
Before iterating over all cache entries, ensure that a sparse index is
expanded to a full one to avoid 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/merge-index.c

index 38ea6ad6ca25d5a969afdbfc5b3510ba44e49a33..c0383fe9df9a3eb2e34f8c5869f996ebc81fce2e 100644 (file)
@@ -58,6 +58,8 @@ static void merge_one_path(const char *path)
 static void merge_all(void)
 {
        int i;
+       /* TODO: audit for interaction with sparse-index. */
+       ensure_full_index(&the_index);
        for (i = 0; i < active_nr; i++) {
                const struct cache_entry *ce = active_cache[i];
                if (!ce_stage(ce))
@@ -80,6 +82,9 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix)
 
        read_cache();
 
+       /* TODO: audit for interaction with sparse-index. */
+       ensure_full_index(&the_index);
+
        i = 1;
        if (!strcmp(argv[i], "-o")) {
                one_shot = 1;