Skip to content

Commit 7589e63

Browse files
committed
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
2 parents e52c6bb + f8adbec commit 7589e63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+394
-296
lines changed

apply.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4020,7 +4020,7 @@ static int read_apply_cache(struct apply_state *state)
40204020
return read_index_from(state->repo->index, state->index_file,
40214021
get_git_dir());
40224022
else
4023-
return read_index(state->repo->index);
4023+
return repo_read_index(state->repo);
40244024
}
40254025

40264026
/* This function tries to read the object name from the current index */
@@ -4713,7 +4713,8 @@ static int apply_patch(struct apply_state *state,
47134713
state->index_file,
47144714
LOCK_DIE_ON_ERROR);
47154715
else
4716-
hold_locked_index(&state->lock_file, LOCK_DIE_ON_ERROR);
4716+
repo_hold_locked_index(state->repo, &state->lock_file,
4717+
LOCK_DIE_ON_ERROR);
47174718
}
47184719

47194720
if (state->check_index && read_apply_cache(state) < 0) {

attr.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* an insanely large number of attributes.
88
*/
99

10-
#define NO_THE_INDEX_COMPATIBILITY_MACROS
1110
#include "cache.h"
1211
#include "config.h"
1312
#include "exec-cmd.h"

blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
188188
unsigned mode;
189189
struct strbuf msg = STRBUF_INIT;
190190

191-
read_index(r->index);
191+
repo_read_index(r);
192192
time(&now);
193193
commit = alloc_commit_node(r);
194194
commit->object.parsed = 1;
@@ -270,7 +270,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,
270270
* want to run "diff-index --cached".
271271
*/
272272
discard_index(r->index);
273-
read_index(r->index);
273+
repo_read_index(r);
274274

275275
len = strlen(path);
276276
if (!mode) {

builtin/add.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* Copyright (C) 2006 Linus Torvalds
55
*/
6+
#define USE_THE_INDEX_COMPATIBILITY_MACROS
67
#include "cache.h"
78
#include "config.h"
89
#include "builtin.h"

builtin/am.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* Based on git-am.sh by Junio C Hamano.
55
*/
6+
#define USE_THE_INDEX_COMPATIBILITY_MACROS
67
#include "cache.h"
78
#include "config.h"
89
#include "builtin.h"
@@ -511,7 +512,7 @@ static int copy_notes_for_rebase(const struct am_state *state)
511512
}
512513

513514
finish:
514-
finish_copy_notes_for_rewrite(c, msg);
515+
finish_copy_notes_for_rewrite(the_repository, c, msg);
515516
fclose(fp);
516517
strbuf_release(&sb);
517518
return ret;
@@ -1529,7 +1530,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
15291530
* changes.
15301531
*/
15311532

1532-
init_merge_options(&o);
1533+
init_merge_options(&o, the_repository);
15331534

15341535
o.branch1 = "HEAD";
15351536
their_tree_name = xstrfmt("%.*s", linelen(state->msg), state->msg);
@@ -1703,7 +1704,7 @@ static void am_run(struct am_state *state, int resume)
17031704

17041705
refresh_and_write_cache();
17051706

1706-
if (index_has_changes(&the_index, NULL, &sb)) {
1707+
if (repo_index_has_changes(the_repository, NULL, &sb)) {
17071708
write_state_bool(state, "dirtyindex", 1);
17081709
die(_("Dirty index: cannot apply patches (dirty: %s)"), sb.buf);
17091710
}
@@ -1761,7 +1762,7 @@ static void am_run(struct am_state *state, int resume)
17611762
* the result may have produced the same tree as ours.
17621763
*/
17631764
if (!apply_status &&
1764-
!index_has_changes(&the_index, NULL, NULL)) {
1765+
!repo_index_has_changes(the_repository, NULL, NULL)) {
17651766
say(state, stdout, _("No changes -- Patch already applied."));
17661767
goto next;
17671768
}
@@ -1815,7 +1816,7 @@ static void am_resolve(struct am_state *state)
18151816

18161817
say(state, stdout, _("Applying: %.*s"), linelen(state->msg), state->msg);
18171818

1818-
if (!index_has_changes(&the_index, NULL, NULL)) {
1819+
if (!repo_index_has_changes(the_repository, NULL, NULL)) {
18191820
printf_ln(_("No changes - did you forget to use 'git add'?\n"
18201821
"If there is nothing left to stage, chances are that something else\n"
18211822
"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)
22712272
/* Ensure a valid committer ident can be constructed */
22722273
git_committer_info(IDENT_STRICT);
22732274

2274-
if (read_index_preload(&the_index, NULL, 0) < 0)
2275+
if (repo_read_index_preload(the_repository, NULL, 0) < 0)
22752276
die(_("failed to read the index"));
22762277

22772278
if (in_progress) {

builtin/blame.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
10071007
long bottom, top;
10081008
if (parse_range_arg(range_list.items[range_i].string,
10091009
nth_line_cb, &sb, lno, anchor,
1010-
&bottom, &top, sb.path, &the_index))
1010+
&bottom, &top, sb.path,
1011+
the_repository->index))
10111012
usage(blame_usage);
10121013
if ((!lno && (top || bottom)) || lno < bottom)
10131014
die(Q_("file %s has only %lu line",

builtin/cat-file.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* Copyright (C) Linus Torvalds, 2005
55
*/
6+
#define USE_THE_INDEX_COMPATIBILITY_MACROS
67
#include "cache.h"
78
#include "config.h"
89
#include "builtin.h"
@@ -73,7 +74,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
7374
if (unknown_type)
7475
flags |= OBJECT_INFO_ALLOW_UNKNOWN_TYPE;
7576

76-
if (get_oid_with_context(obj_name, GET_OID_RECORD_PATH,
77+
if (get_oid_with_context(the_repository, obj_name,
78+
GET_OID_RECORD_PATH,
7779
&oid, &obj_context))
7880
die("Not a valid object name %s", obj_name);
7981

@@ -382,7 +384,8 @@ static void batch_one_object(const char *obj_name,
382384
int flags = opt->follow_symlinks ? GET_OID_FOLLOW_SYMLINKS : 0;
383385
enum get_oid_result result;
384386

385-
result = get_oid_with_context(obj_name, flags, &data->oid, &ctx);
387+
result = get_oid_with_context(the_repository, obj_name,
388+
flags, &data->oid, &ctx);
386389
if (result != FOUND) {
387390
switch (result) {
388391
case MISSING_OBJECT:

builtin/check-attr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define USE_THE_INDEX_COMPATIBILITY_MACROS
12
#include "builtin.h"
23
#include "cache.h"
34
#include "config.h"

builtin/check-ignore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define USE_THE_INDEX_COMPATIBILITY_MACROS
12
#include "builtin.h"
23
#include "cache.h"
34
#include "config.h"

builtin/checkout-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright (C) 2005 Linus Torvalds
55
*
66
*/
7+
#define USE_THE_INDEX_COMPATIBILITY_MACROS
78
#include "builtin.h"
89
#include "config.h"
910
#include "lockfile.h"

0 commit comments

Comments
 (0)