{reset,merge}: call discard_index() before returning

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>

Ævar Arnfjörð Bjarmason committed Nov 8, 2022 at 19:17 UTC ab2cf37183eb461f1a5176a4d58650e7c8f642eb
2 files changed +3
builtin/merge.c
+1
@@ -1794,5 +1794,6 @@ done:
1794 }
1795 strbuf_release(&buf);
1796 free(branch_to_free);
1797 + discard_index(&the_index);
1798 return ret;
1799 }
builtin/reset.c
+2
@@ -481,5 +481,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
481 if (!pathspec.nr)
482 remove_branch_state(the_repository, 0);
483
484 + discard_index(&the_index);
485 +
486 return update_ref_status;
487 }