Commit 7589e636 authored by Junio C Hamano's avatar Junio C Hamano

Merge branch 'nd/the-index-final'

The assumption to work on the single "in-core index" instance has
been reduced from the library-ish part of the codebase.

* nd/the-index-final:
  cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch
  read-cache.c: remove the_* from index_has_changes()
  merge-recursive.c: remove implicit dependency on the_repository
  merge-recursive.c: remove implicit dependency on the_index
  sha1-name.c: remove implicit dependency on the_index
  read-cache.c: replace update_index_if_able with repo_&
  read-cache.c: kill read_index()
  checkout: avoid the_index when possible
  repository.c: replace hold_locked_index() with repo_hold_locked_index()
  notes-utils.c: remove the_repository references
  grep: use grep_opt->repo instead of explict repo argument
parents e52c6bbd f8adbec9
......@@ -4020,7 +4020,7 @@ static int read_apply_cache(struct apply_state *state)
return read_index_from(state->repo->index, state->index_file,
get_git_dir());
else
return read_index(state->repo->index);
return repo_read_index(state->repo);
}
/* This function tries to read the object name from the current index */
......@@ -4713,7 +4713,8 @@ static int apply_patch(struct apply_state *state,
state->index_file,
LOCK_DIE_ON_ERROR);
else
hold_locked_index(&state->lock_file, LOCK_DIE_ON_ERROR);
repo_hold_locked_index(state->repo, &state->lock_file,
LOCK_DIE_ON_ERROR);
}
if (state->check_index && read_apply_cache(state) < 0) {
......
......@@ -7,7 +7,6 @@
* an insanely large number of attributes.
*/
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "exec-cmd.h"
......
......@@ -188,7 +188,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
unsigned mode;
struct strbuf msg = STRBUF_INIT;
read_index(r->index);
repo_read_index(r);
time(&now);
commit = alloc_commit_node(r);
commit->object.parsed = 1;
......@@ -270,7 +270,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
* want to run "diff-index --cached".
*/
discard_index(r->index);
read_index(r->index);
repo_read_index(r);
len = strlen(path);
if (!mode) {
......
......@@ -3,6 +3,7 @@
*
* Copyright (C) 2006 Linus Torvalds
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"
......
......@@ -3,6 +3,7 @@
*
* Based on git-am.sh by Junio C Hamano.
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"
......@@ -511,7 +512,7 @@ static int copy_notes_for_rebase(const struct am_state *state)
}
finish:
finish_copy_notes_for_rewrite(c, msg);
finish_copy_notes_for_rewrite(the_repository, c, msg);
fclose(fp);
strbuf_release(&sb);
return ret;
......@@ -1529,7 +1530,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
* changes.
*/
init_merge_options(&o);
init_merge_options(&o, the_repository);
o.branch1 = "HEAD";
their_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg);
......@@ -1703,7 +1704,7 @@ static void am_run(struct am_state *state, int resume)
refresh_and_write_cache();
if (index_has_changes(&the_index, NULL, &sb)) {
if (repo_index_has_changes(the_repository, NULL, &sb)) {
write_state_bool(state, "dirtyindex", 1);
die(_("Dirty index: cannot apply patches (dirty: %s)"), sb.buf);
}
......@@ -1761,7 +1762,7 @@ static void am_run(struct am_state *state, int resume)
* the result may have produced the same tree as ours.
*/
if (!apply_status &&
!index_has_changes(&the_index, NULL, NULL)) {
!repo_index_has_changes(the_repository, NULL, NULL)) {
say(state, stdout, _("No changes -- Patch already applied."));
goto next;
}
......@@ -1815,7 +1816,7 @@ static void am_resolve(struct am_state *state)
say(state, stdout, _("Applying: %.*s"), linelen(state->msg), state->msg);
if (!index_has_changes(&the_index, NULL, NULL)) {
if (!repo_index_has_changes(the_repository, NULL, NULL)) {
printf_ln(_("No changes - did you forget to use 'git add'?\n"
"If there is nothing left to stage, chances are that something else\n"
"already introduced the same changes; you might want to skip this patch."));
......@@ -2271,7 +2272,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) {
......
......@@ -1007,7 +1007,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
long bottom, top;
if (parse_range_arg(range_list.items[range_i].string,
nth_line_cb, &sb, lno, anchor,
&bottom, &top, sb.path, &the_index))
&bottom, &top, sb.path,
the_repository->index))
usage(blame_usage);
if ((!lno && (top || bottom)) || lno < bottom)
die(Q_("file %s has only %lu line",
......
......@@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"
......@@ -73,7 +74,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
if (unknown_type)
flags |= OBJECT_INFO_ALLOW_UNKNOWN_TYPE;
if (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,
if (get_oid_with_context(the_repository, obj_name,
GET_OID_RECORD_PATH,
&oid, &obj_context))
die("Not a valid object name %s", obj_name);
......@@ -382,7 +384,8 @@ static void batch_one_object(const char *obj_name,
int flags = opt->follow_symlinks ? GET_OID_FOLLOW_SYMLINKS : 0;
enum get_oid_result result;
result = get_oid_with_context(obj_name, flags, &data->oid, &ctx);
result = get_oid_with_context(the_repository, obj_name,
flags, &data->oid, &ctx);
if (result != FOUND) {
switch (result) {
case MISSING_OBJECT:
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"
......
......@@ -4,6 +4,7 @@
* Copyright (C) 2005 Linus Torvalds
*
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "lockfile.h"
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "checkout.h"
......@@ -288,7 +289,7 @@ static int checkout_paths(const struct checkout_opts *opts,
return run_add_interactive(revision, "--patch=checkout",
&opts->pathspec);
hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
if (read_cache_preload(&opts->pathspec) < 0)
return error(_("index file corrupt"));
......@@ -701,7 +702,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
* a pain; plumb in an option to set
* o.renormalize?
*/
init_merge_options(&o);
init_merge_options(&o, the_repository);
o.verbosity = 0;
work = write_tree_from_memory(&o);
......
......@@ -6,6 +6,7 @@
* Based on git-clean.sh by Pavel Roskin
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"
......
......@@ -8,6 +8,7 @@
* Clone a repository into a different directory that does not yet exist.
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "lockfile.h"
......
......@@ -5,6 +5,7 @@
* Based on git-commit.sh by Junio C Hamano and Linus Torvalds
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"
......@@ -1368,7 +1369,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);
......@@ -1397,7 +1398,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
wt_status_collect(&s);
if (0 <= fd)
update_index_if_able(&the_index, &index_lock);
repo_update_index_if_able(the_repository, &index_lock);
if (s.relative_paths)
s.prefix = prefix;
......@@ -1675,7 +1676,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
run_commit_hook(use_editor, get_index_file(), "post-commit", NULL);
if (amend && !no_post_rewrite) {
commit_post_rewrite(current_head, &oid);
commit_post_rewrite(the_repository, current_head, &oid);
}
if (!quiet) {
unsigned int flags = 0;
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"
......@@ -634,7 +635,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
NULL, NULL, NULL);
fd = hold_locked_index(&index_lock, 0);
if (0 <= fd)
update_index_if_able(&the_index, &index_lock);
repo_update_index_if_able(the_repository, &index_lock);
repo_init_revisions(the_repository, &revs, prefix);
argv_array_pushv(&args, diff_index_args);
......
......@@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"
......@@ -165,7 +166,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)) {
......
......@@ -3,6 +3,7 @@
*
* Copyright (c) 2006 Junio C Hamano
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"
......@@ -212,7 +213,7 @@ static void refresh_index_quietly(void)
discard_cache();
read_cache();
refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
update_index_if_able(&the_index, &lock_file);
repo_update_index_if_able(the_repository, &lock_file);
}
static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv)
......
......@@ -11,6 +11,7 @@
*
* Copyright (C) 2016 Johannes Schindelin
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "repository.h"
......
......@@ -3,6 +3,7 @@
*
* Copyright (c) 2006 Junio C Hamano
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "repository.h"
#include "config.h"
......@@ -393,21 +394,22 @@ static void run_pager(struct grep_opt *opt, const char *prefix)
exit(status);
}
static int grep_cache(struct grep_opt *opt, struct repository *repo,
static int grep_cache(struct grep_opt *opt,
const struct pathspec *pathspec, int cached);
static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
struct tree_desc *tree, struct strbuf *base, int tn_len,
int check_attr, struct repository *repo);
int check_attr);
static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
static int grep_submodule(struct grep_opt *opt,
const struct pathspec *pathspec,
const struct object_id *oid,
const char *filename, const char *path)
{
struct repository subrepo;
struct repository *superproject = opt->repo;
const struct submodule *sub = submodule_from_path(superproject,
&null_oid, path);
struct grep_opt subopt;
int hit;
/*
......@@ -443,6 +445,9 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
add_to_alternates_memory(subrepo.objects->odb->path);
grep_read_unlock();
memcpy(&subopt, opt, sizeof(subopt));
subopt.repo = &subrepo;
if (oid) {
struct object *object;
struct tree_desc tree;
......@@ -464,21 +469,22 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
strbuf_addch(&base, '/');
init_tree_desc(&tree, data, size);
hit = grep_tree(opt, pathspec, &tree, &base, base.len,
object->type == OBJ_COMMIT, &subrepo);
hit = grep_tree(&subopt, pathspec, &tree, &base, base.len,
object->type == OBJ_COMMIT);
strbuf_release(&base);
free(data);
} else {
hit = grep_cache(opt, &subrepo, pathspec, 1);
hit = grep_cache(&subopt, pathspec, 1);
}
repo_clear(&subrepo);
return hit;
}
static int grep_cache(struct grep_opt *opt, struct repository *repo,
static int grep_cache(struct grep_opt *opt,
const struct pathspec *pathspec, int cached)
{
struct repository *repo = opt->repo;
int hit = 0;
int nr;
struct strbuf name = STRBUF_INIT;
......@@ -516,7 +522,7 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo,
}
} else if (recurse_submodules && S_ISGITLINK(ce->ce_mode) &&
submodule_path_match(repo->index, pathspec, name.buf, NULL)) {
hit |= grep_submodule(opt, repo, pathspec, NULL, ce->name, ce->name);
hit |= grep_submodule(opt, pathspec, NULL, ce->name, ce->name);
} else {
continue;
}
......@@ -538,8 +544,9 @@ static int grep_cache(struct grep_opt *opt, struct repository *repo,
static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
struct tree_desc *tree, struct strbuf *base, int tn_len,
int check_attr, struct repository *repo)
int check_attr)
{
struct repository *repo = opt->repo;
int hit = 0;
enum interesting match = entry_not_interesting;
struct name_entry entry;
......@@ -586,10 +593,10 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
strbuf_addch(base, '/');
init_tree_desc(&sub, data, size);
hit |= grep_tree(opt, pathspec, &sub, base, tn_len,
check_attr, repo);
check_attr);
free(data);
} else if (recurse_submodules && S_ISGITLINK(entry.mode)) {
hit |= grep_submodule(opt, repo, pathspec, &entry.oid,
hit |= grep_submodule(opt, pathspec, &entry.oid,
base->buf, base->buf + tn_len);
}
......@@ -631,7 +638,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
}
init_tree_desc(&tree, data, size);
hit = grep_tree(opt, pathspec, &tree, &base, base.len,
obj->type == OBJ_COMMIT, the_repository);
obj->type == OBJ_COMMIT);
strbuf_release(&base);
free(data);
return hit;
......@@ -648,12 +655,12 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
for (i = 0; i < nr; i++) {
struct object *real_obj;
real_obj = deref_tag(the_repository, list->objects[i].item,
real_obj = deref_tag(opt->repo, list->objects[i].item,
NULL, 0);
/* load the gitmodules file for this rev */
if (recurse_submodules) {
submodule_free(the_repository);
submodule_free(opt->repo);
gitmodules_config_oid(&real_obj->oid);
}
if (grep_object(opt, pathspec, real_obj, list->objects[i].name,
......@@ -678,9 +685,9 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec,
if (exc_std)
setup_standard_excludes(&dir);
fill_directory(&dir, &the_index, pathspec);
fill_directory(&dir, opt->repo->index, pathspec);
for (i = 0; i < dir.nr; i++) {
if (!dir_path_match(&the_index, dir.entries[i], pathspec, 0, NULL))
if (!dir_path_match(opt->repo->index, dir.entries[i], pathspec, 0, NULL))
continue;
hit |= grep_file(opt, dir.entries[i]->name);
if (hit && opt->status_only)
......@@ -1018,7 +1025,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
break;
}
if (get_oid_with_context(arg, GET_OID_RECORD_PATH,
if (get_oid_with_context(the_repository, arg,
GET_OID_RECORD_PATH,
&oid, &oc)) {
if (seen_dashdash)
die(_("unable to resolve revision: %s"), arg);
......@@ -1121,7 +1129,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
if (!cached)
setup_work_tree();
hit = grep_cache(&opt, the_repository, &pathspec, cached);
hit = grep_cache(&opt, &pathspec, cached);
} else {
if (cached)
die(_("both --cached and trees are given"));
......
......@@ -40,7 +40,8 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
if (fstat(fd, &st) < 0 ||
(literally
? hash_literally(&oid, fd, type, flags)
: index_fd(&the_index, &oid, fd, &st, type_from_string(type), path, flags)))
: index_fd(the_repository->index, &oid, fd, &st,
type_from_string(type), path, flags)))
die((flags & HASH_WRITE_OBJECT)
? "Unable to add %s to database"
: "Unable to hash %s", path);
......
......@@ -4,6 +4,7 @@
* (C) Copyright 2006 Linus Torvalds
* 2006 Junio Hamano
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "refs.h"
......@@ -509,7 +510,8 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
!rev->diffopt.flags.allow_textconv)
return stream_blob_to_fd(1, oid, NULL, 0);
if (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,
if (get_oid_with_context(the_repository, obj_name,
GET_OID_RECORD_PATH,
&oidc, &obj_context))
die(_("Not a valid object name %s"), obj_name);
if (!obj_context.path ||
......
......@@ -5,7 +5,6 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "repository.h"
#include "config.h"
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "run-command.h"
......
......@@ -7,6 +7,7 @@
*
* Pretend we resolved the heads, but declare our tree trumps everybody else.
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "git-compat-util.h"
#include "builtin.h"
#include "diff.h"
......
......@@ -29,7 +29,7 @@ int cmd_merge_recursive(int argc, const char **argv, const char *prefix)
char *better1, *better2;
struct commit *result;
init_merge_options(&o);
init_merge_options(&o, the_repository);
if (argv[0] && ends_with(argv[0], "-subtree"))
o.subtree_shift = "";
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "tree-walk.h"
#include "xdiff-interface.h"
......@@ -76,7 +77,8 @@ static void *result(struct merge_list *entry, unsigned long *size)
their = NULL;
if (entry)
their = entry->blob;
return merge_blobs(&the_index, path, base, our, their, size);
return merge_blobs(the_repository->index, path,
base, our, their, size);
}
static void *origin(struct merge_list *entry, unsigned long *size)
......
......@@ -6,6 +6,7 @@
* Based on git-merge.sh by Junio C Hamano.
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "parse-options.h"
......@@ -702,7 +703,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
return 2;
}
init_merge_options(&o);
init_merge_options(&o, the_repository);
if (!strcmp(strategy, "subtree"))
o.subtree_shift = "";
......
......@@ -3,6 +3,7 @@
*
* Copyright (C) 2006 Johannes Schindelin
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "pathspec.h"
......
......@@ -330,10 +330,10 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
}
if (!rewrite_cmd) {
commit_notes(t, msg);
commit_notes(the_repository, t, msg);
free_notes(t);
} else {
finish_copy_notes_for_rewrite(c, msg);
finish_copy_notes_for_rewrite(the_repository, c, msg);
}
strbuf_release(&buf);
return ret;
......@@ -469,12 +469,14 @@ static int add(int argc, const char **argv, const char *prefix)
write_note_data(&d, &new_note);
if (add_note(t, &object, &new_note, combine_notes_overwrite))
BUG("combine_notes_overwrite failed");
commit_notes(t, "Notes added by 'git notes add'");
commit_notes(the_repository, t,
"Notes added by 'git notes add'");
} else {
fprintf(stderr, _("Removing note for object %s\n"),
oid_to_hex(&object));
remove_note(t, object.hash);
commit_notes(t, "Notes removed by 'git notes add'");
commit_notes(the_repository, t,
"Notes removed by 'git notes add'");
}
free_note_data(&d);
......@@ -552,7 +554,8 @@ static int copy(int argc, const char **argv, const char *prefix)
if (add_note(t, &object, from_note, combine_notes_overwrite))
BUG("combine_notes_overwrite failed");
commit_notes(t, "Notes added by 'git notes copy'");
commit_notes(the_repository, t,
"Notes added by 'git notes copy'");
out:
free_notes(t);
return retval;
......@@ -636,7 +639,7 @@ static int append_edit(int argc, const char **argv, const char *prefix)
remove_note(t, object.hash);
logmsg = xstrfmt("Notes removed by 'git notes %s'", argv[0]);
}
commit_notes(t, logmsg);
commit_notes(the_repository, t, logmsg);
free(logmsg);
free_note_data(&d);
......@@ -937,7 +940,8 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
strbuf_release(&sb);
}
if (!retval)
commit_notes(t, "Notes removed by 'git notes remove'");
commit_notes(the_repository, t,
"Notes removed by 'git notes remove'");
free_notes(t);
return retval;
}
......@@ -965,7 +969,8 @@ static int prune(int argc, const char **argv, const char *prefix)
prune_notes(t, (verbose ? NOTES_PRUNE_VERBOSE : 0) |
(show_only ? NOTES_PRUNE_VERBOSE|NOTES_PRUNE_DRYRUN : 0) );
if (!show_only)
commit_notes(t, "Notes removed by 'git notes prune'");
commit_notes(the_repository, t,
"Notes removed by 'git notes prune'");
free_notes(t);
return 0;
}
......
......@@ -970,7 +970,7 @@ static int no_try_delta(const char *path)
if (!check)
check = attr_check_initl("delta", NULL);
git_check_attr(&the_index, path, check);
git_check_attr(the_repository->index, path, check);
if (ATTR_FALSE(check->items[0].value))
return 1;
return 0;
......
......@@ -5,6 +5,7 @@
*
* Fetch one or more remote refs and merge it/them into the current HEAD.
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"
......
......@@ -4,6 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"
......
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"
......
......@@ -4,6 +4,7 @@
* Copyright (c) 2018 Pratik Karki
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "run-command.h"
#include "exec-cmd.h"
......@@ -419,7 +420,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;
}
......@@ -1233,13 +1234,12 @@ 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);
if (0 <= fd)
update_index_if_able(the_repository->index,
&lock_file);
repo_update_index_if_able(the_repository, &lock_file);
rollback_lock_file(&lock_file);
if (has_unstaged_changes(the_repository, 1)) {
......@@ -1591,7 +1591,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) {
......@@ -1601,7 +1601,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
fd = hold_locked_index(&lock_file, 0);
refresh_cache(REFRESH_QUIET);
if (0 <= fd)
update_index_if_able(&the_index, &lock_file);