{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>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2022-11-08 19:17:38 +01:00 committed by Junio C Hamano
parent e5e37517dd
commit ab2cf37183
2 changed files with 3 additions and 0 deletions

View file

@ -1794,5 +1794,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
}
strbuf_release(&buf);
free(branch_to_free);
discard_index(&the_index);
return ret;
}

View 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;
}