Skip to content

Commit 1b374ad

Browse files
pks-tgitster
authored andcommitted
add-interactive: stop using the_repository
Stop using `the_repository` in the "add-interactive" subsystem by reusing the repository we already have available via parameters or in the `add_i_state` structure. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 727c71a commit 1b374ad

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

add-interactive.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
21
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
@@ -72,14 +71,14 @@ void init_add_i_state(struct add_i_state *s, struct repository *r)
7271
s->use_color ? GIT_COLOR_RESET : "", COLOR_MAXLEN);
7372

7473
FREE_AND_NULL(s->interactive_diff_filter);
75-
git_config_get_string("interactive.difffilter",
76-
&s->interactive_diff_filter);
74+
repo_config_get_string(r, "interactive.difffilter",
75+
&s->interactive_diff_filter);
7776

7877
FREE_AND_NULL(s->interactive_diff_algorithm);
79-
git_config_get_string("diff.algorithm",
80-
&s->interactive_diff_algorithm);
78+
repo_config_get_string(r, "diff.algorithm",
79+
&s->interactive_diff_algorithm);
8180

82-
git_config_get_bool("interactive.singlekey", &s->use_single_key);
81+
repo_config_get_bool(r, "interactive.singlekey", &s->use_single_key);
8382
if (s->use_single_key)
8483
setbuf(stdin, NULL);
8584
}
@@ -535,7 +534,7 @@ static int get_modified_files(struct repository *r,
535534
size_t *binary_count)
536535
{
537536
struct object_id head_oid;
538-
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
537+
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(r),
539538
"HEAD", RESOLVE_REF_READING,
540539
&head_oid, NULL);
541540
struct collection_status s = { 0 };
@@ -560,7 +559,7 @@ static int get_modified_files(struct repository *r,
560559
s.skip_unseen = filter && i;
561560

562561
opt.def = is_initial ?
563-
empty_tree_oid_hex(the_repository->hash_algo) : oid_to_hex(&head_oid);
562+
empty_tree_oid_hex(r->hash_algo) : oid_to_hex(&head_oid);
564563

565564
repo_init_revisions(r, &rev, NULL);
566565
setup_revisions(0, NULL, &rev, &opt);
@@ -765,7 +764,7 @@ static int run_revert(struct add_i_state *s, const struct pathspec *ps,
765764
size_t count, i, j;
766765

767766
struct object_id oid;
768-
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
767+
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(s->r),
769768
"HEAD", RESOLVE_REF_READING,
770769
&oid,
771770
NULL);
@@ -996,7 +995,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
996995
ssize_t count, i;
997996

998997
struct object_id oid;
999-
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
998+
int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(s->r),
1000999
"HEAD", RESOLVE_REF_READING,
10011000
&oid,
10021001
NULL);

0 commit comments

Comments
 (0)