]> git.ipfire.org Git - thirdparty/git.git/commitdiff
apply.c: make init_apply_state() take a struct repository
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Mon, 13 Aug 2018 16:14:39 +0000 (18:14 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Aug 2018 21:14:44 +0000 (14:14 -0700)
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 <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
apply.h
builtin/am.c
builtin/apply.c

diff --git a/apply.c b/apply.c
index 572cd639a66183be9bfd88fbec060807b27bc6e8..3704850ef2830c1d0c9d2fd15bc4fbd8a9ce9560 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -76,10 +76,12 @@ static int parse_ignorewhitespace_option(struct apply_state *state,
 }
 
 int init_apply_state(struct apply_state *state,
+                    struct repository *repo,
                     const char *prefix)
 {
        memset(state, 0, sizeof(*state));
        state->prefix = prefix;
+       state->repo = repo;
        state->apply = 1;
        state->line_termination = '\n';
        state->p_value = 1;
diff --git a/apply.h b/apply.h
index 01963b5ec4eec9352de36c41cae0138d8eb1d049..78c8bcfc3c4afe5ebd583f58c76eb3ca0e19a702 100644 (file)
--- a/apply.h
+++ b/apply.h
@@ -1,6 +1,8 @@
 #ifndef APPLY_H
 #define APPLY_H
 
+struct repository;
+
 enum apply_ws_error_action {
        nowarn_ws_error,
        warn_on_ws_error,
@@ -62,6 +64,7 @@ struct apply_state {
        int unsafe_paths;
 
        /* Other non boolean parameters */
+       struct repository *repo;
        const char *index_file;
        enum apply_verbosity apply_verbosity;
        const char *fake_ancestor;
@@ -116,6 +119,7 @@ int apply_parse_options(int argc, const char **argv,
                        int *force_apply, int *options,
                        const char * const *apply_usage);
 int init_apply_state(struct apply_state *state,
+                    struct repository *repo,
                     const char *prefix);
 void clear_apply_state(struct apply_state *state);
 int check_apply_state(struct apply_state *state, int force_apply);
index 2c19e69f585a46330718ddea1c13a095cefe9d19..9f7ecf6ecb7711c35277fa827c4c2afc0dfba867 100644 (file)
@@ -1464,7 +1464,7 @@ static int run_apply(const struct am_state *state, const char *index_file)
        int force_apply = 0;
        int options = 0;
 
-       if (init_apply_state(&apply_state, NULL))
+       if (init_apply_state(&apply_state, the_repository, NULL))
                BUG("init_apply_state() failed");
 
        argv_array_push(&apply_opts, "apply");
index 48d3989331d9b7deeb034642a027729bd1267e38..3f099b960565ff2944209ba514ea7274dad852f5 100644 (file)
@@ -16,7 +16,7 @@ int cmd_apply(int argc, const char **argv, const char *prefix)
        int ret;
        struct apply_state state;
 
-       if (init_apply_state(&state, prefix))
+       if (init_apply_state(&state, the_repository, prefix))
                exit(128);
 
        argc = apply_parse_options(argc, argv,