builtin: stop using the_index
Convert builtins to use `the_repository->index` instead of `the_index`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
319ba14407
commit
f59aa5e0a9
@ -7,7 +7,7 @@
|
||||
*
|
||||
* Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
|
||||
*/
|
||||
#define USE_THE_INDEX_VARIABLE
|
||||
|
||||
#include "builtin.h"
|
||||
#include "advice.h"
|
||||
#include "config.h"
|
||||
@ -66,8 +66,8 @@ static int reset_index(const char *ref, const struct object_id *oid, int reset_t
|
||||
|
||||
memset(&opts, 0, sizeof(opts));
|
||||
opts.head_idx = 1;
|
||||
opts.src_index = &the_index;
|
||||
opts.dst_index = &the_index;
|
||||
opts.src_index = the_repository->index;
|
||||
opts.dst_index = the_repository->index;
|
||||
opts.fn = oneway_merge;
|
||||
opts.merge = 1;
|
||||
init_checkout_metadata(&opts.meta, ref, oid, NULL);
|
||||
@ -159,11 +159,11 @@ static void update_index_from_diff(struct diff_queue_struct *q,
|
||||
struct cache_entry *ce;
|
||||
|
||||
if (!is_in_reset_tree && !intent_to_add) {
|
||||
remove_file_from_index(&the_index, one->path);
|
||||
remove_file_from_index(the_repository->index, one->path);
|
||||
continue;
|
||||
}
|
||||
|
||||
ce = make_cache_entry(&the_index, one->mode, &one->oid, one->path,
|
||||
ce = make_cache_entry(the_repository->index, one->mode, &one->oid, one->path,
|
||||
0, 0);
|
||||
|
||||
/*
|
||||
@ -174,9 +174,9 @@ static void update_index_from_diff(struct diff_queue_struct *q,
|
||||
* if this entry is outside the sparse cone - this is necessary
|
||||
* to properly construct the reset sparse directory.
|
||||
*/
|
||||
pos = index_name_pos(&the_index, one->path, strlen(one->path));
|
||||
if ((pos >= 0 && ce_skip_worktree(the_index.cache[pos])) ||
|
||||
(pos < 0 && !path_in_sparse_checkout(one->path, &the_index)))
|
||||
pos = index_name_pos(the_repository->index, one->path, strlen(one->path));
|
||||
if ((pos >= 0 && ce_skip_worktree(the_repository->index->cache[pos])) ||
|
||||
(pos < 0 && !path_in_sparse_checkout(one->path, the_repository->index)))
|
||||
ce->ce_flags |= CE_SKIP_WORKTREE;
|
||||
|
||||
if (!ce)
|
||||
@ -186,7 +186,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
|
||||
ce->ce_flags |= CE_INTENT_TO_ADD;
|
||||
set_object_name_for_intent_to_add_entry(ce);
|
||||
}
|
||||
add_index_entry(&the_index, ce,
|
||||
add_index_entry(the_repository->index, ce,
|
||||
ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
|
||||
}
|
||||
}
|
||||
@ -208,8 +208,8 @@ static int read_from_tree(const struct pathspec *pathspec,
|
||||
opt.change = diff_change;
|
||||
opt.add_remove = diff_addremove;
|
||||
|
||||
if (pathspec->nr && pathspec_needs_expanded_index(&the_index, pathspec))
|
||||
ensure_full_index(&the_index);
|
||||
if (pathspec->nr && pathspec_needs_expanded_index(the_repository->index, pathspec))
|
||||
ensure_full_index(the_repository->index);
|
||||
|
||||
if (do_diff_cache(tree_oid, &opt))
|
||||
return 1;
|
||||
@ -235,7 +235,7 @@ static void set_reflog_message(struct strbuf *sb, const char *action,
|
||||
|
||||
static void die_if_unmerged_cache(int reset_type)
|
||||
{
|
||||
if (is_merge() || unmerged_index(&the_index))
|
||||
if (is_merge() || unmerged_index(the_repository->index))
|
||||
die(_("Cannot do a %s reset in the middle of a merge."),
|
||||
_(reset_type_names[reset_type]));
|
||||
|
||||
@ -470,12 +470,12 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
||||
update_ref_status = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
the_index.updated_skipworktree = 1;
|
||||
the_repository->index->updated_skipworktree = 1;
|
||||
if (!no_refresh && get_git_work_tree()) {
|
||||
uint64_t t_begin, t_delta_in_ms;
|
||||
|
||||
t_begin = getnanotime();
|
||||
refresh_index(&the_index, flags, NULL, NULL,
|
||||
refresh_index(the_repository->index, flags, NULL, NULL,
|
||||
_("Unstaged changes after reset:"));
|
||||
t_delta_in_ms = (getnanotime() - t_begin) / 1000000;
|
||||
if (!quiet && advice_enabled(ADVICE_RESET_NO_REFRESH_WARNING) && t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) {
|
||||
@ -501,7 +501,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
||||
free(ref);
|
||||
}
|
||||
|
||||
if (write_locked_index(&the_index, &lock, COMMIT_LOCK))
|
||||
if (write_locked_index(the_repository->index, &lock, COMMIT_LOCK))
|
||||
die(_("Could not write new index file."));
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
||||
if (!pathspec.nr)
|
||||
remove_branch_state(the_repository, 0);
|
||||
|
||||
discard_index(&the_index);
|
||||
discard_index(the_repository->index);
|
||||
|
||||
cleanup:
|
||||
clear_pathspec(&pathspec);
|
||||
|
Reference in New Issue
Block a user