Skip to content
Snippets Groups Projects
Commit 7589e636 authored by Junio C Hamano's avatar Junio C Hamano
Browse files

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
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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 */
Loading
Loading
@@ -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) {
Loading
Loading
Loading
Loading
@@ -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"
Loading
Loading
Loading
Loading
@@ -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;
Loading
Loading
@@ -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) {
Loading
Loading
Loading
Loading
@@ -3,6 +3,7 @@
*
* Copyright (C) 2006 Linus Torvalds
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"
Loading
Loading
Loading
Loading
@@ -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"
Loading
Loading
@@ -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;
Loading
Loading
@@ -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);
Loading
Loading
@@ -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);
}
Loading
Loading
@@ -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;
}
Loading
Loading
@@ -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."));
Loading
Loading
@@ -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) {
Loading
Loading
Loading
Loading
@@ -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",
Loading
Loading
Loading
Loading
@@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"
Loading
Loading
@@ -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);
 
Loading
Loading
@@ -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:
Loading
Loading
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"
Loading
Loading
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "cache.h"
#include "config.h"
Loading
Loading
Loading
Loading
@@ -4,6 +4,7 @@
* Copyright (C) 2005 Linus Torvalds
*
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "lockfile.h"
Loading
Loading
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "builtin.h"
#include "config.h"
#include "checkout.h"
Loading
Loading
@@ -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"));
 
Loading
Loading
@@ -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);
 
Loading
Loading
Loading
Loading
@@ -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"
Loading
Loading
Loading
Loading
@@ -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"
Loading
Loading
Loading
Loading
@@ -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"
Loading
Loading
@@ -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);
Loading
Loading
@@ -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;
Loading
Loading
@@ -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;
Loading
Loading
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "lockfile.h"
Loading
Loading
@@ -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);
Loading
Loading
Loading
Loading
@@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"
Loading
Loading
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"
Loading
Loading
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "diff.h"
Loading
Loading
@@ -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)) {
Loading
Loading
Loading
Loading
@@ -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"
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -11,6 +11,7 @@
*
* Copyright (C) 2016 Johannes Schindelin
*/
#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment