read-cache API & users: make discard_index() return void

The discard_index() function has not returned non-zero since
7a51ed66f6 (Make on-disk index representation separate from in-core
one, 2008-01-14), but we've had various code in-tree still acting as
though that might be the case.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2022-11-19 14:07:31 +01:00
committed by Junio C Hamano
parent fbc1ed629e
commit 9c5f3ee3b3
6 changed files with 19 additions and 16 deletions

View File

@@ -530,8 +530,8 @@ static int get_modified_files(struct repository *r,
struct collection_status s = { 0 };
int i;
if (discard_index(r->index) < 0 ||
repo_read_index_preload(r, ps, 0) < 0)
discard_index(r->index);
if (repo_read_index_preload(r, ps, 0) < 0)
return error(_("could not read index"));
prefix_item_list_clear(files);
@@ -1156,8 +1156,8 @@ int run_add_i(struct repository *r, const struct pathspec *ps)
_("staged"), _("unstaged"), _("path"));
opts.list_opts.header = header.buf;
if (discard_index(r->index) < 0 ||
repo_read_index(r) < 0 ||
discard_index(r->index);
if (repo_read_index(r) < 0 ||
repo_refresh_and_write_index(r, REFRESH_QUIET, 0, 1,
NULL, NULL, NULL) < 0)
warning(_("could not refresh index"));