Commit 11877b9e authored by Junio C Hamano's avatar Junio C Hamano

Merge branch 'nd/the-index'

Various codepaths in the core-ish part learn to work on an
arbitrary in-core index structure, not necessarily the default
instance "the_index".

* nd/the-index: (23 commits)
  revision.c: reduce implicit dependency the_repository
  revision.c: remove implicit dependency on the_index
  ws.c: remove implicit dependency on the_index
  tree-diff.c: remove implicit dependency on the_index
  submodule.c: remove implicit dependency on the_index
  line-range.c: remove implicit dependency on the_index
  userdiff.c: remove implicit dependency on the_index
  rerere.c: remove implicit dependency on the_index
  sha1-file.c: remove implicit dependency on the_index
  patch-ids.c: remove implicit dependency on the_index
  merge.c: remove implicit dependency on the_index
  merge-blobs.c: remove implicit dependency on the_index
  ll-merge.c: remove implicit dependency on the_index
  diff-lib.c: remove implicit dependency on the_index
  read-cache.c: remove implicit dependency on the_index
  diff.c: remove implicit dependency on the_index
  grep.c: remove implicit dependency on the_index
  diff.c: remove the_index dependency in textconv() functions
  blame.c: rename "repo" argument to "r"
  combine-diff.c: remove implicit dependency on the_index
  ...
parents aef8e71f b3c7eef9
......@@ -18,8 +18,8 @@ Calling sequence
----------------
* Prepare `struct diff_options` to record the set of diff options, and
then call `diff_setup()` to initialize this structure. This sets up
the vanilla default.
then call `repo_diff_setup()` to initialize this structure. This
sets up the vanilla default.
* Fill in the options structure to specify desired output format, rename
detection, etc. `diff_opt_parse()` can be used to parse options given
......
......@@ -15,9 +15,9 @@ revision list.
Functions
---------
`init_revisions`::
`repo_init_revisions`::
Initialize a rev_info structure with default values. The second
Initialize a rev_info structure with default values. The third
parameter may be NULL or can be prefix path, and then the `.prefix`
variable will be set to it. This is typically the first function you
want to call when you want to deal with a revision list. After calling
......
......@@ -2131,10 +2131,12 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si
if (!use_patch(state, patch))
patch->ws_rule = 0;
else if (patch->new_name)
patch->ws_rule = whitespace_rule(state->repo->index,
patch->new_name);
else
patch->ws_rule = whitespace_rule(patch->new_name
? patch->new_name
: patch->old_name);
patch->ws_rule = whitespace_rule(state->repo->index,
patch->old_name);
patchsize = parse_single_patch(state,
buffer + offset + hdrsize,
......@@ -3467,7 +3469,8 @@ static int load_preimage(struct apply_state *state,
return 0;
}
static int three_way_merge(struct image *image,
static int three_way_merge(struct apply_state *state,
struct image *image,
char *path,
const struct object_id *base,
const struct object_id *ours,
......@@ -3483,7 +3486,9 @@ static int three_way_merge(struct image *image,
status = ll_merge(&result, path,
&base_file, "base",
&our_file, "ours",
&their_file, "theirs", NULL);
&their_file, "theirs",
state->repo->index,
NULL);
free(base_file.ptr);
free(our_file.ptr);
free(their_file.ptr);
......@@ -3595,7 +3600,7 @@ static int try_threeway(struct apply_state *state,
clear_image(&tmp_image);
/* in-core three-way merge between post and our using pre as base */
status = three_way_merge(image, patch->new_name,
status = three_way_merge(state, image, patch->new_name,
&pre_oid, &our_oid, &post_oid);
if (status < 0) {
if (state->apply_verbosity > verbosity_silent)
......@@ -4627,7 +4632,7 @@ static int write_out_results(struct apply_state *state, struct patch *list)
}
string_list_clear(&cpath, 0);
rerere(0);
repo_rerere(state->repo, 0);
}
return errs;
......
......@@ -264,9 +264,10 @@ static int has_only_ascii(const char *s)
}
}
static int entry_is_binary(const char *path, const void *buffer, size_t size)
static int entry_is_binary(struct index_state *istate, const char *path,
const void *buffer, size_t size)
{
struct userdiff_driver *driver = userdiff_find_by_path(path);
struct userdiff_driver *driver = userdiff_find_by_path(istate, path);
if (!driver)
driver = userdiff_find_by_name("default");
if (driver->binary != -1)
......@@ -352,7 +353,8 @@ static int write_zip_entry(struct archiver_args *args,
return error(_("cannot read %s"),
oid_to_hex(oid));
crc = crc32(crc, buffer, size);
is_binary = entry_is_binary(path_without_prefix,
is_binary = entry_is_binary(args->repo->index,
path_without_prefix,
buffer, size);
out = buffer;
}
......@@ -428,7 +430,8 @@ static int write_zip_entry(struct archiver_args *args,
break;
crc = crc32(crc, buf, readlen);
if (is_binary == -1)
is_binary = entry_is_binary(path_without_prefix,
is_binary = entry_is_binary(args->repo->index,
path_without_prefix,
buf, readlen);
write_or_die(1, buf, readlen);
}
......@@ -460,7 +463,8 @@ static int write_zip_entry(struct archiver_args *args,
break;
crc = crc32(crc, buf, readlen);
if (is_binary == -1)
is_binary = entry_is_binary(path_without_prefix,
is_binary = entry_is_binary(args->repo->index,
path_without_prefix,
buf, readlen);
zstream.next_in = buf;
......
......@@ -392,7 +392,7 @@ static void parse_treeish_arg(const char **argv,
if (get_oid(name, &oid))
die("Not a valid object name");
commit = lookup_commit_reference_gently(the_repository, &oid, 1);
commit = lookup_commit_reference_gently(ar_args->repo, &oid, 1);
if (commit) {
commit_sha1 = commit->object.oid.hash;
archive_time = commit->date;
......
......@@ -633,7 +633,7 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
struct argv_array rev_argv = ARGV_ARRAY_INIT;
int i;
init_revisions(revs, prefix);
repo_init_revisions(the_repository, revs, prefix);
revs->abbrev = 0;
revs->commit_format = CMIT_FMT_UNSPECIFIED;
......@@ -890,7 +890,7 @@ static void show_diff_tree(const char *prefix, struct commit *commit)
struct rev_info opt;
/* diff-tree init */
init_revisions(&opt, prefix);
repo_init_revisions(the_repository, &opt, prefix);
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
opt.abbrev = 0;
opt.diff = 1;
......
......@@ -90,7 +90,7 @@ static struct blame_origin *get_origin(struct commit *commit, const char *path)
static void verify_working_tree_path(struct repository *repo,
static void verify_working_tree_path(struct repository *r,
struct commit *work_tree, const char *path)
{
struct commit_list *parents;
......@@ -102,15 +102,15 @@ static void verify_working_tree_path(struct repository *repo,
unsigned mode;
if (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&
oid_object_info(repo, &blob_oid, NULL) == OBJ_BLOB)
oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)
return;
}
pos = index_name_pos(repo->index, path, strlen(path));
pos = index_name_pos(r->index, path, strlen(path));
if (pos >= 0)
; /* path is in the index */
else if (-1 - pos < repo->index->cache_nr &&
!strcmp(repo->index->cache[-1 - pos]->name, path))
else if (-1 - pos < r->index->cache_nr &&
!strcmp(r->index->cache[-1 - pos]->name, path))
; /* path is in the index, unmerged */
else
die("no such path '%s' in HEAD", path);
......@@ -166,7 +166,7 @@ static void set_commit_buffer_from_strbuf(struct commit *c, struct strbuf *sb)
* Prepare a dummy commit that represents the work tree (or staged) item.
* Note that annotating work tree item never works in the reverse.
*/
static struct commit *fake_working_tree_commit(struct repository *repo,
static struct commit *fake_working_tree_commit(struct repository *r,
struct diff_options *opt,
const char *path,
const char *contents_from)
......@@ -183,7 +183,7 @@ static struct commit *fake_working_tree_commit(struct repository *repo,
unsigned mode;
struct strbuf msg = STRBUF_INIT;
read_index(repo->index);
read_index(r->index);
time(&now);
commit = alloc_commit_node(the_repository);
commit->object.parsed = 1;
......@@ -195,7 +195,7 @@ static struct commit *fake_working_tree_commit(struct repository *repo,
parent_tail = append_parent(parent_tail, &head_oid);
append_merge_parents(parent_tail);
verify_working_tree_path(repo, commit, path);
verify_working_tree_path(r, commit, path);
origin = make_origin(commit, path);
......@@ -234,7 +234,7 @@ static struct commit *fake_working_tree_commit(struct repository *repo,
switch (st.st_mode & S_IFMT) {
case S_IFREG:
if (opt->flags.allow_textconv &&
textconv_object(read_from, mode, &null_oid, 0, &buf_ptr, &buf_len))
textconv_object(r, read_from, mode, &null_oid, 0, &buf_ptr, &buf_len))
strbuf_attach(&buf, buf_ptr, buf_len, buf_len + 1);
else if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
die_errno("cannot open or read '%s'", read_from);
......@@ -253,7 +253,7 @@ static struct commit *fake_working_tree_commit(struct repository *repo,
if (strbuf_read(&buf, 0, 0) < 0)
die_errno("failed to read from stdin");
}
convert_to_git(repo->index, path, buf.buf, buf.len, &buf, 0);
convert_to_git(r->index, path, buf.buf, buf.len, &buf, 0);
origin->file.ptr = buf.buf;
origin->file.size = buf.len;
pretend_object_file(buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);
......@@ -264,28 +264,28 @@ static struct commit *fake_working_tree_commit(struct repository *repo,
* bits; we are not going to write this index out -- we just
* want to run "diff-index --cached".
*/
discard_index(repo->index);
read_index(repo->index);
discard_index(r->index);
read_index(r->index);
len = strlen(path);
if (!mode) {
int pos = index_name_pos(repo->index, path, len);
int pos = index_name_pos(r->index, path, len);
if (0 <= pos)
mode = repo->index->cache[pos]->ce_mode;
mode = r->index->cache[pos]->ce_mode;
else
/* Let's not bother reading from HEAD tree */
mode = S_IFREG | 0644;
}
ce = make_empty_cache_entry(repo->index, len);
ce = make_empty_cache_entry(r->index, len);
oidcpy(&ce->oid, &origin->blob_oid);
memcpy(ce->name, path, len);
ce->ce_flags = create_ce_flags(0);
ce->ce_namelen = len;
ce->ce_mode = create_ce_mode(mode);
add_index_entry(repo->index, ce,
add_index_entry(r->index, ce,
ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
cache_tree_invalidate_path(repo->index, path);
cache_tree_invalidate_path(r->index, path);
return commit;
}
......@@ -318,7 +318,8 @@ static void fill_origin_blob(struct diff_options *opt,
(*num_read_blob)++;
if (opt->flags.allow_textconv &&
textconv_object(o->path, o->mode, &o->blob_oid, 1, &file->ptr, &file_size))
textconv_object(opt->repo, o->path, o->mode,
&o->blob_oid, 1, &file->ptr, &file_size))
;
else
file->ptr = read_object_file(&o->blob_oid, &type,
......@@ -520,14 +521,14 @@ static void queue_blames(struct blame_scoreboard *sb, struct blame_origin *porig
*
* This also fills origin->mode for corresponding tree path.
*/
static int fill_blob_sha1_and_mode(struct repository *repo,
static int fill_blob_sha1_and_mode(struct repository *r,
struct blame_origin *origin)
{
if (!is_null_oid(&origin->blob_oid))
return 0;
if (get_tree_entry(&origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
goto error_out;
if (oid_object_info(repo, &origin->blob_oid, NULL) != OBJ_BLOB)
if (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)
goto error_out;
return 0;
error_out:
......@@ -540,8 +541,9 @@ static int fill_blob_sha1_and_mode(struct repository *repo,
* We have an origin -- check if the same path exists in the
* parent and return an origin structure to represent it.
*/
static struct blame_origin *find_origin(struct commit *parent,
struct blame_origin *origin)
static struct blame_origin *find_origin(struct repository *r,
struct commit *parent,
struct blame_origin *origin)
{
struct blame_origin *porigin;
struct diff_options diff_opts;
......@@ -561,7 +563,7 @@ static struct blame_origin *find_origin(struct commit *parent,
* and origin first. Most of the time they are the
* same and diff-tree is fairly efficient about this.
*/
diff_setup(&diff_opts);
repo_diff_setup(r, &diff_opts);
diff_opts.flags.recursive = 1;
diff_opts.detect_rename = 0;
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
......@@ -628,14 +630,15 @@ static struct blame_origin *find_origin(struct commit *parent,
* We have an origin -- find the path that corresponds to it in its
* parent and return an origin structure to represent it.
*/
static struct blame_origin *find_rename(struct commit *parent,
struct blame_origin *origin)
static struct blame_origin *find_rename(struct repository *r,
struct commit *parent,
struct blame_origin *origin)
{
struct blame_origin *porigin = NULL;
struct diff_options diff_opts;
int i;
diff_setup(&diff_opts);
repo_diff_setup(r, &diff_opts);
diff_opts.flags.recursive = 1;
diff_opts.detect_rename = DIFF_DETECT_RENAME;
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
......@@ -1259,7 +1262,7 @@ static void find_copy_in_parent(struct blame_scoreboard *sb,
if (!unblamed)
return; /* nothing remains for this target */
diff_setup(&diff_opts);
repo_diff_setup(sb->repo, &diff_opts);
diff_opts.flags.recursive = 1;
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
......@@ -1441,7 +1444,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
* common cases, then we look for renames in the second pass.
*/
for (pass = 0; pass < 2 - sb->no_whole_file_rename; pass++) {
struct blame_origin *(*find)(struct commit *, struct blame_origin *);
struct blame_origin *(*find)(struct repository *, struct commit *, struct blame_origin *);
find = pass ? find_rename : find_origin;
for (i = 0, sg = first_scapegoat(revs, commit, sb->reverse);
......@@ -1454,7 +1457,7 @@ static void pass_blame(struct blame_scoreboard *sb, struct blame_origin *origin,
continue;
if (parse_commit(p))
continue;
porigin = find(p, origin);
porigin = find(sb->repo, p, origin);
if (!porigin)
continue;
if (oideq(&porigin->blob_oid, &origin->blob_oid)) {
......@@ -1857,7 +1860,7 @@ void setup_scoreboard(struct blame_scoreboard *sb,
die(_("no such path %s in %s"), path, final_commit_name);
if (sb->revs->diffopt.flags.allow_textconv &&
textconv_object(path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
textconv_object(sb->repo, path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
&sb->final_buf_size))
;
else
......
......@@ -110,7 +110,7 @@ int add_files_to_cache(const char *prefix,
memset(&data, 0, sizeof(data));
data.flags = flags;
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
setup_revisions(0, NULL, &rev, NULL);
if (pathspec)
copy_pathspec(&rev.prune_data, pathspec);
......@@ -232,7 +232,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
if (read_cache() < 0)
die(_("Could not read the index"));
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
rev.diffopt.context = 7;
argc = setup_revisions(argc, argv, &rev, NULL);
......
......@@ -1376,7 +1376,7 @@ static void write_commit_patch(const struct am_state *state, struct commit *comm
FILE *fp;
fp = xfopen(am_path(state, "patch"), "w");
init_revisions(&rev_info, NULL);
repo_init_revisions(the_repository, &rev_info, NULL);
rev_info.diff = 1;
rev_info.abbrev = 0;
rev_info.disable_stdin = 1;
......@@ -1411,7 +1411,7 @@ static void write_index_patch(const struct am_state *state)
the_repository->hash_algo->empty_tree);
fp = xfopen(am_path(state, "patch"), "w");
init_revisions(&rev_info, NULL);
repo_init_revisions(the_repository, &rev_info, NULL);
rev_info.diff = 1;
rev_info.disable_stdin = 1;
rev_info.no_commit_id = 1;
......@@ -1569,7 +1569,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
struct rev_info rev_info;
const char *diff_filter_str = "--diff-filter=AM";
init_revisions(&rev_info, NULL);
repo_init_revisions(the_repository, &rev_info, NULL);
rev_info.diffopt.output_format = DIFF_FORMAT_NAME_STATUS;
diff_opt_parse(&rev_info.diffopt, &diff_filter_str, 1, rev_info.prefix);
add_pending_oid(&rev_info, "HEAD", &our_tree, 0);
......@@ -1608,7 +1608,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
o.verbosity = 0;
if (merge_recursive_generic(&o, &our_tree, &their_tree, 1, bases, &result)) {
rerere(state->allow_rerere_autoupdate);
repo_rerere(the_repository, state->allow_rerere_autoupdate);
free(their_tree_name);
return error(_("Failed to merge in the changes."));
}
......@@ -1903,7 +1903,7 @@ static void am_resolve(struct am_state *state)
goto next;
}
rerere(0);
repo_rerere(the_repository, 0);
do_commit(state);
......
......@@ -830,7 +830,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
setup_default_color_by_age();
git_config(git_blame_config, &output_option);
init_revisions(&revs, NULL);
repo_init_revisions(the_repository, &revs, NULL);
revs.date_mode = blame_date_mode;
revs.diffopt.flags.allow_textconv = 1;
revs.diffopt.flags.follow_renames = 1;
......@@ -1001,7 +1001,7 @@ 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))
&bottom, &top, sb.path, &the_index))
usage(blame_usage);
if ((!lno && (top || bottom)) || lno < bottom)
die(Q_("file %s has only %lu line",
......
......@@ -113,7 +113,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
die("git cat-file --textconv %s: <object> must be <sha1:path>",
obj_name);
if (textconv_object(path, obj_context.mode, &oid, 1, &buf, &size))
if (textconv_object(the_repository, path, obj_context.mode,
&oid, 1, &buf, &size))
break;
/* else fallthrough */
......@@ -305,7 +306,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
oid_to_hex(oid), data->rest);
} else if (opt->cmdmode == 'c') {
enum object_type type;
if (!textconv_object(data->rest, 0100644, oid,
if (!textconv_object(the_repository,
data->rest, 0100644, oid,
1, &contents, &size))
contents = read_object_file(oid,
&type,
......
......@@ -214,7 +214,8 @@ static int checkout_merged(int pos, const struct checkout *state)
* merge.renormalize set, too
*/
status = ll_merge(&result_buf, path, &ancestor, "base",
&ours, "ours", &theirs, "theirs", NULL);
&ours, "ours", &theirs, "theirs",
state->istate, NULL);
free(ancestor.ptr);
free(ours.ptr);
free(theirs.ptr);
......@@ -397,7 +398,7 @@ static void show_local_changes(struct object *head,
{
struct rev_info rev;
/* I think we want full paths, even if we're in a subdirectory. */
init_revisions(&rev, NULL);
repo_init_revisions(the_repository, &rev, NULL);
rev.diffopt.flags = opts->flags;
rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
diff_setup_done(&rev.diffopt);
......@@ -899,7 +900,7 @@ static void orphaned_commit_warning(struct commit *old_commit, struct commit *ne
struct rev_info revs;
struct object *object = &old_commit->object;
init_revisions(&revs, NULL);
repo_init_revisions(the_repository, &revs, NULL);
setup_revisions(0, NULL, &revs, NULL);
object->flags &= ~UNINTERESTING;
......
......@@ -983,7 +983,7 @@ static const char *find_author_by_nickname(const char *name)
const char *av[20];
int ac = 0;
init_revisions(&revs, NULL);
repo_init_revisions(the_repository, &revs, NULL);
strbuf_addf(&buf, "--author=%s", name);
av[++ac] = "--all";
av[++ac] = "-i";
......@@ -1657,7 +1657,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (git_env_bool(GIT_TEST_COMMIT_GRAPH, 0))
write_commit_graph_reachable(get_object_directory(), 0, 0);
rerere(0);
repo_rerere(the_repository, 0);
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) {
......
......@@ -488,7 +488,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
"--objects", "--in-commit-order", "--reverse", "HEAD",
NULL);
init_revisions(&revs, NULL);
repo_init_revisions(the_repository, &revs, NULL);
if (setup_revisions(args.argc, args.argv, &revs, NULL) > 1)
BUG("setup_revisions could not handle all args?");
......@@ -636,7 +636,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
if (0 <= fd)
update_index_if_able(&the_index, &index_lock);
init_revisions(&revs, prefix);
repo_init_revisions(the_repository, &revs, prefix);
argv_array_pushv(&args, diff_index_args);
if (setup_revisions(args.argc, args.argv, &revs, NULL) != 1)
BUG("malformed internal diff-index command line");
......
......@@ -25,7 +25,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
usage(diff_files_usage);
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
rev.abbrev = 0;
precompose_argv(argc, argv);
......
......@@ -22,7 +22,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
usage(diff_cache_usage);
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
rev.abbrev = 0;
precompose_argv(argc, argv);
......
......@@ -110,7 +110,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
usage(diff_tree_usage);
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
init_revisions(opt, prefix);
repo_init_revisions(the_repository, opt, prefix);
if (read_cache() < 0)
die(_("index file corrupt"));
opt->abbrev = 0;
......
......@@ -318,7 +318,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
git_config(git_diff_ui_config, NULL);
precompose_argv(argc, argv);
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
if (no_index && argc != i + 2) {
if (no_index == DIFF_NO_INDEX_IMPLICIT) {
......@@ -339,7 +339,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
}
if (no_index)
/* If this is a no-index diff, just run it and exit there. */
diff_no_index(&rev, argc, argv);
diff_no_index(the_repository, &rev, argc, argv);
/* Otherwise, we are doing the usual "git" diff */
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
......
......@@ -112,7 +112,7 @@ static int use_wt_file(const char *workdir, const char *name,
int fd = open(buf.buf, O_RDONLY);
if (fd >= 0 &&
!index_fd(&wt_oid, fd, &st, OBJ_BLOB, name, 0)) {
!index_fd(&the_index, &wt_oid, fd, &st, OBJ_BLOB, name, 0)) {
if (is_null_oid(oid)) {
oidcpy(oid, &wt_oid);
use = 1;
......
......@@ -1033,7 +1033,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
/* we handle encodings */
git_config(git_default_config, NULL);
init_revisions(&revs, prefix);
repo_init_revisions(the_repository, &revs, prefix);
init_revision_sources(&revision_sources);
revs.topo_order = 1;
revs.sources = &revision_sources;
......
......@@ -643,7 +643,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
struct rev_info rev;
head = lookup_commit_or_die(&head_oid, "HEAD");
init_revisions(&rev, NULL);
repo_init_revisions(the_repository, &rev, NULL);
rev.commit_format = CMIT_FMT_ONELINE;
rev.ignore_merges = 1;
rev.limited = 1;
......
......@@ -103,7 +103,8 @@ static void add_work(struct grep_opt *opt, const struct grep_source *gs)
todo[todo_end].source = *gs;
if (opt->binary != GREP_BINARY_TEXT)
grep_source_load_driver(&todo[todo_end].source);
grep_source_load_driver(&todo[todo_end].source,
opt->repo->index);
todo[todo_end].done = 0;
strbuf_reset(&todo[todo_end].out);
todo_end = (todo_end + 1) % ARRAY_SIZE(todo);
......@@ -904,9 +905,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
OPT_END()
};
init_grep_defaults();
init_grep_defaults(the_repository);
git_config(grep_cmd_config, NULL);
grep_init(&opt, prefix);
grep_init(&opt, the_repository, prefix);
/*
* If there is no -- then the paths must exist in the working
......
......@@ -40,7 +40,7 @@ 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(&oid, fd, &st, type_from_string(type), path, flags)))
: index_fd(&the_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);
......
......@@ -118,7 +118,7 @@ static int log_line_range_callback(const struct option *option, const char *arg,
static void init_log_defaults(void)
{
init_grep_defaults();
init_grep_defaults(the_repository);
init_diff_ui_defaults();
decoration_style = auto_decoration_style();
......@@ -470,7 +470,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
init_log_defaults();
git_config(git_log_config, NULL);
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
rev.diff = 1;
rev.simplify_history = 0;
memset(&opt, 0, sizeof(opt));
......@@ -510,7 +510,8 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
&oidc, &obj_context))
die(_("Not a valid object name %s"), obj_name);
if (!obj_context.path ||
!textconv_object(obj_context.path, obj_context.mode, &oidc, 1, &buf, &size)) {
!textconv_object(the_repository, obj_context.path,
obj_context.mode, &oidc, 1, &buf, &size)) {
free(obj_context.path);
return stream_blob_to_fd(1, oid, NULL, 0);
}
......@@ -587,7 +588,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
git_config(git_log_config, NULL);
memset(&match_all, 0, sizeof(match_all));
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
rev.diff = 1;
rev.always_show_header = 1;
rev.no_walk = REVISION_WALK_NO_WALK_SORTED;
......@@ -667,7 +668,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
init_log_defaults();
git_config(git_log_config, NULL);
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
init_reflog_walk(&rev.reflog_info);
rev.verbose_header = 1;
memset(&opt, 0, sizeof(opt));
......@@ -706,7 +707,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)
init_log_defaults();
git_config(git_log_config, NULL);
init_revisions(&rev, prefix);
repo_init_revisions(the_repository, &rev, prefix);
rev.always_show_header = 1;
memset(&opt, 0, sizeof(opt));
opt.def = "HEAD";
......@@ -916,10 +917,10 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
die(_("Not a range."));
init_patch_ids(ids);
init_patch_ids(the_repository, ids);
/* given a range a..b get all patch ids for b..a */
init_revisions(&check_rev, rev->prefix);
repo_init_revisions(the_repository, &check_rev, rev->prefix);
check_rev.max_parents = 1;
o1->flags ^= UNINTERESTING;
o2->flags ^= UNINTERESTING;
......@@ -1377,13 +1378,13 @@ static void prepare_bases(struct base_tree_info *bases,
return;