]> git.ipfire.org Git - thirdparty/git.git/commitdiff
{reset,merge}: call discard_index() before returning
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 8 Nov 2022 18:17:38 +0000 (19:17 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Nov 2022 03:32:48 +0000 (12:32 +0900)
These two built-ins both deal with the index, but weren't discarding
it. In subsequent commits we'll add more free()-ing to discard_index()
that we've missed, but let's first call the existing function.

We can doubtless add discard_index() (or its alias discard_cache()) to
a lot more places, but let's just add it here for now.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
builtin/merge.c
builtin/reset.c

index 5900b81729d8da757d04613781d41f2e7621ebcd..a6698adbfd3d201a94e7450735406710b1e5e144 100644 (file)
@@ -1794,5 +1794,6 @@ done:
        }
        strbuf_release(&buf);
        free(branch_to_free);
+       discard_index(&the_index);
        return ret;
 }
index fdce6f8c85670c8b2b0e20304336debba3190408..69f18a248ee44c0f2eef5d2dd0cc5de1082698e9 100644 (file)
@@ -481,5 +481,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
        if (!pathspec.nr)
                remove_branch_state(the_repository, 0);
 
+       discard_index(&the_index);
+
        return update_ref_status;
 }