]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/am.c
am: let command-line options override saved options
[thirdparty/git.git] / builtin / am.c
index 3c503920138c567bb756f093d9c684eae8f66834..f81b74dd0b91cbcf84d2df87414805ffbaa7e06e 100644 (file)
@@ -152,6 +152,8 @@ static void am_state_init(struct am_state *state, const char *dir)
 
        state->prec = 4;
 
+       git_config_get_bool("am.threeway", &state->threeway);
+
        state->utf8 = 1;
 
        git_config_get_bool("am.messageid", &state->message_id);
@@ -1777,7 +1779,6 @@ static void am_run(struct am_state *state, int resume)
 
                if (resume) {
                        validate_resume_state(state);
-                       resume = 0;
                } else {
                        int skip;
 
@@ -1839,6 +1840,10 @@ static void am_run(struct am_state *state, int resume)
 
 next:
                am_next(state);
+
+               if (resume)
+                       am_load(state);
+               resume = 0;
        }
 
        if (!is_empty_file(am_path(state, "rewritten"))) {
@@ -1893,6 +1898,7 @@ static void am_resolve(struct am_state *state)
 
 next:
        am_next(state);
+       am_load(state);
        am_run(state, 0);
 }
 
@@ -2020,6 +2026,7 @@ static void am_skip(struct am_state *state)
                die(_("failed to clean index"));
 
        am_next(state);
+       am_load(state);
        am_run(state, 0);
 }
 
@@ -2130,6 +2137,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
        int keep_cr = -1;
        int patch_format = PATCH_FORMAT_UNKNOWN;
        enum resume_mode resume = RESUME_FALSE;
+       int in_progress;
 
        const char * const usage[] = {
                N_("git am [options] [(<mbox>|<Maildir>)...]"),
@@ -2221,35 +2229,27 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                OPT_END()
        };
 
-       /*
-        * NEEDSWORK: Once all the features of git-am.sh have been
-        * re-implemented in builtin/am.c, this preamble can be removed.
-        */
-       if (!getenv("_GIT_USE_BUILTIN_AM")) {
-               const char *path = mkpath("%s/git-am", git_exec_path());
-
-               if (sane_execvp(path, (char **)argv) < 0)
-                       die_errno("could not exec %s", path);
-       } else {
-               prefix = setup_git_directory();
-               trace_repo_setup(prefix);
-               setup_work_tree();
-       }
-
        git_config(git_default_config, NULL);
 
        am_state_init(&state, git_path("rebase-apply"));
 
+       in_progress = am_in_progress(&state);
+       if (in_progress)
+               am_load(&state);
+
        argc = parse_options(argc, argv, prefix, options, usage, 0);
 
        if (binary >= 0)
                fprintf_ln(stderr, _("The -b/--binary option has been a no-op for long time, and\n"
                                "it will be removed. Please do not use it anymore."));
 
+       /* Ensure a valid committer ident can be constructed */
+       git_committer_info(IDENT_STRICT);
+
        if (read_index_preload(&the_index, NULL) < 0)
                die(_("failed to read the index"));
 
-       if (am_in_progress(&state)) {
+       if (in_progress) {
                /*
                 * Catch user error to feed us patches when there is a session
                 * in progress:
@@ -2267,8 +2267,6 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 
                if (resume == RESUME_FALSE)
                        resume = RESUME_APPLY;
-
-               am_load(&state);
        } else {
                struct argv_array paths = ARGV_ARRAY_INIT;
                int i;