Skip to content

Commit 82ea77e

Browse files
pcloudsgitster
authored andcommitted
apply.c: make init_apply_state() take a struct repository
We're moving away from the_index in this code. "struct index_state *" could be added to struct apply_state. But let's aim long term and put struct repository here instead so that we could even avoid more global states in the future. The index will be available via apply_state->repo->index. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 332a82a commit 82ea77e

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

apply.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ static int parse_ignorewhitespace_option(struct apply_state *state,
7676
}
7777

7878
int init_apply_state(struct apply_state *state,
79+
struct repository *repo,
7980
const char *prefix)
8081
{
8182
memset(state, 0, sizeof(*state));
8283
state->prefix = prefix;
84+
state->repo = repo;
8385
state->apply = 1;
8486
state->line_termination = '\n';
8587
state->p_value = 1;

apply.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef APPLY_H
22
#define APPLY_H
33

4+
struct repository;
5+
46
enum apply_ws_error_action {
57
nowarn_ws_error,
68
warn_on_ws_error,
@@ -62,6 +64,7 @@ struct apply_state {
6264
int unsafe_paths;
6365

6466
/* Other non boolean parameters */
67+
struct repository *repo;
6568
const char *index_file;
6669
enum apply_verbosity apply_verbosity;
6770
const char *fake_ancestor;
@@ -116,6 +119,7 @@ int apply_parse_options(int argc, const char **argv,
116119
int *force_apply, int *options,
117120
const char * const *apply_usage);
118121
int init_apply_state(struct apply_state *state,
122+
struct repository *repo,
119123
const char *prefix);
120124
void clear_apply_state(struct apply_state *state);
121125
int check_apply_state(struct apply_state *state, int force_apply);

builtin/am.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
14641464
int force_apply = 0;
14651465
int options = 0;
14661466

1467-
if (init_apply_state(&apply_state, NULL))
1467+
if (init_apply_state(&apply_state, the_repository, NULL))
14681468
BUG("init_apply_state() failed");
14691469

14701470
argv_array_push(&apply_opts, "apply");

builtin/apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
1616
int ret;
1717
struct apply_state state;
1818

19-
if (init_apply_state(&state, prefix))
19+
if (init_apply_state(&state, the_repository, prefix))
2020
exit(128);
2121

2222
argc = apply_parse_options(argc, argv,

0 commit comments

Comments
 (0)