]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/commit.c
Merge branch 'pw/rebase-i-more-options'
[thirdparty/git.git] / builtin / commit.c
index 2785344fed621ce3ce62db3bf9c9d26b552d2601..5d91b13a5c37e0e1477d05d86cfdd53fe21995a4 100644 (file)
@@ -847,21 +847,19 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                        if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS &&
                                !merge_contains_scissors)
                                wt_status_add_cut_line(s->fp);
-                       status_printf_ln(s, GIT_COLOR_NORMAL,
-                           whence == FROM_MERGE
-                               ? _("\n"
-                                       "It looks like you may be committing a merge.\n"
-                                       "If this is not correct, please remove the file\n"
-                                       "       %s\n"
-                                       "and try again.\n")
-                               : _("\n"
-                                       "It looks like you may be committing a cherry-pick.\n"
-                                       "If this is not correct, please remove the file\n"
-                                       "       %s\n"
-                                       "and try again.\n"),
+                       status_printf_ln(
+                               s, GIT_COLOR_NORMAL,
                                whence == FROM_MERGE ?
-                                       git_path_merge_head(the_repository) :
-                                       git_path_cherry_pick_head(the_repository));
+                                             _("\n"
+                                         "It looks like you may be committing a merge.\n"
+                                         "If this is not correct, please run\n"
+                                         "     git update-ref -d MERGE_HEAD\n"
+                                         "and try again.\n") :
+                                             _("\n"
+                                         "It looks like you may be committing a cherry-pick.\n"
+                                         "If this is not correct, please run\n"
+                                         "     git update-ref -d CHERRY_PICK_HEAD\n"
+                                         "and try again.\n"));
                }
 
                fprintf(s->fp, "\n");
@@ -1005,15 +1003,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
                return 0;
 
        if (use_editor) {
-               struct argv_array env = ARGV_ARRAY_INIT;
+               struct strvec env = STRVEC_INIT;
 
-               argv_array_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
-               if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
+               strvec_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
+               if (launch_editor(git_path_commit_editmsg(), NULL, env.v)) {
                        fprintf(stderr,
                        _("Please supply the message using either -m or -F option.\n"));
                        exit(1);
                }
-               argv_array_clear(&env);
+               strvec_clear(&env);
        }
 
        if (!no_verify &&
@@ -1372,9 +1370,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
                         N_("show stash information")),
                OPT_BOOL(0, "ahead-behind", &s.ahead_behind_flags,
                         N_("compute full ahead/behind values")),
-               { OPTION_CALLBACK, 0, "porcelain", &status_format,
+               OPT_CALLBACK_F(0, "porcelain", &status_format,
                  N_("version"), N_("machine-readable output"),
-                 PARSE_OPT_OPTARG, opt_parse_porcelain },
+                 PARSE_OPT_OPTARG, opt_parse_porcelain),
                OPT_SET_INT(0, "long", &status_format,
                            N_("show status in long format (default)"),
                            STATUS_FORMAT_LONG),
@@ -1393,9 +1391,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
                  PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
                OPT_COLUMN(0, "column", &s.colopts, N_("list untracked files in columns")),
                OPT_BOOL(0, "no-renames", &no_renames, N_("do not detect renames")),
-               { OPTION_CALLBACK, 'M', "find-renames", &rename_score_arg,
+               OPT_CALLBACK_F('M', "find-renames", &rename_score_arg,
                  N_("n"), N_("detect renames, optionally set similarity index"),
-                 PARSE_OPT_OPTARG | PARSE_OPT_NONEG, opt_parse_rename_score },
+                 PARSE_OPT_OPTARG | PARSE_OPT_NONEG, opt_parse_rename_score),
                OPT_END(),
        };
 
@@ -1494,7 +1492,6 @@ static int git_commit_config(const char *k, const char *v, void *cb)
 
 int cmd_commit(int argc, const char **argv, const char *prefix)
 {
-       const char *argv_gc_auto[] = {"gc", "--auto", NULL};
        static struct wt_status s;
        static struct option builtin_commit_options[] = {
                OPT__QUIET(&quiet, N_("suppress summary after successful commit")),
@@ -1700,12 +1697,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                      "new_index file. Check that disk is not full and quota is\n"
                      "not exceeded, and then \"git restore --staged :/\" to recover."));
 
-       if (git_env_bool(GIT_TEST_COMMIT_GRAPH, 0) &&
-           write_commit_graph_reachable(the_repository->objects->odb, 0, NULL))
-               return 1;
+       git_test_write_commit_graph_or_die();
 
        repo_rerere(the_repository, 0);
-       run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+       run_auto_gc(quiet);
        run_commit_hook(use_editor, get_index_file(), "post-commit", NULL);
        if (amend && !no_post_rewrite) {
                commit_post_rewrite(the_repository, current_head, &oid);
@@ -1721,6 +1716,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
                                     &oid, flags);
        }
 
+       apply_autostash(git_path_merge_autostash(the_repository));
+
        UNLEAK(err);
        UNLEAK(sb);
        return 0;