From e1ff0a32e48eb0f3e53970df3f941d183093ff5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 12 Jan 2019 09:13:26 +0700 Subject: read-cache.c: kill read_index() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit read_index() shares the same problem as hold_locked_index(): it assumes $GIT_DIR/index. Move all call sites to repo_read_index() instead. read_index_preload() and read_index_unmerged() are also killed as a consequence. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/am.c | 2 +- builtin/commit.c | 2 +- builtin/diff-tree.c | 2 +- builtin/rebase.c | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'builtin') diff --git a/builtin/am.c b/builtin/am.c index d32044545d..901dc55078 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -2278,7 +2278,7 @@ int cmd_am(int argc, const char **argv, const char *prefix) /* Ensure a valid committer ident can be constructed */ git_committer_info(IDENT_STRICT); - if (read_index_preload(&the_index, NULL, 0) < 0) + if (repo_read_index_preload(the_repository, NULL, 0) < 0) die(_("failed to read the index")); if (in_progress) { diff --git a/builtin/commit.c b/builtin/commit.c index e29fb5e3eb..19eb6cff86 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1367,7 +1367,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) if (status_format != STATUS_FORMAT_PORCELAIN && status_format != STATUS_FORMAT_PORCELAIN_V2) progress_flag = REFRESH_PROGRESS; - read_index(&the_index); + repo_read_index(the_repository); refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED|progress_flag, &s.pathspec, NULL, NULL); diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index ef996126d7..42bc1eb41d 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -165,7 +165,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix) if (opt->diffopt.detect_rename) { if (!the_index.cache) - read_index(&the_index); + repo_read_index(the_repository); opt->diffopt.setup |= DIFF_SETUP_USE_SIZE_CACHE; } while (fgets(line, sizeof(line), stdin)) { diff --git a/builtin/rebase.c b/builtin/rebase.c index 00de70365e..ce5f5b5a17 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -576,7 +576,7 @@ static int reset_head(struct object_id *oid, const char *action, if (!detach_head) unpack_tree_opts.reset = 1; - if (read_index_unmerged(the_repository->index) < 0) { + if (repo_read_index_unmerged(the_repository) < 0) { ret = error(_("could not read index")); goto leave_reset_head; } @@ -1015,7 +1015,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) die(_("Cannot read HEAD")); fd = hold_locked_index(&lock_file, 0); - if (read_index(the_repository->index) < 0) + if (repo_read_index(the_repository) < 0) die(_("could not read index")); refresh_index(the_repository->index, REFRESH_QUIET, NULL, NULL, NULL); @@ -1368,7 +1368,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) get_fork_point(options.upstream_name, head); } - if (read_index(the_repository->index) < 0) + if (repo_read_index(the_repository) < 0) die(_("could not read index")); if (options.autostash) { @@ -1423,7 +1423,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) putchar('\n'); if (discard_index(the_repository->index) < 0 || - read_index(the_repository->index) < 0) + repo_read_index(the_repository) < 0) die(_("could not read index")); } } -- cgit v1.2.3