]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: support amending commits
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 21 Oct 2016 12:25:17 +0000 (14:25 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Oct 2016 16:32:34 +0000 (09:32 -0700)
This teaches the run_git_commit() function to take an argument that will
allow us to implement "todo" commands that need to amend the commit
messages ("fixup", "squash" and "reword").

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c

index c0a0aa0ed62b164f615da7b024bdb1610b3b7c37..1ef50a0999c241e20c29272ed9688c340eceac87 100644 (file)
@@ -484,7 +484,7 @@ static char **read_author_script(void)
  * author metadata.
  */
 static int run_git_commit(const char *defmsg, struct replay_opts *opts,
-                         int allow_empty, int edit)
+                         int allow_empty, int edit, int amend)
 {
        char **env = NULL;
        struct argv_array array;
@@ -513,6 +513,8 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
        argv_array_push(&array, "commit");
        argv_array_push(&array, "-n");
 
+       if (amend)
+               argv_array_push(&array, "--amend");
        if (opts->gpg_sign)
                argv_array_pushf(&array, "-S%s", opts->gpg_sign);
        if (opts->signoff)
@@ -786,7 +788,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
        }
        if (!opts->no_commit)
                res = run_git_commit(opts->edit ? NULL : git_path_merge_msg(),
-                                    opts, allow, opts->edit);
+                                    opts, allow, opts->edit, 0);
 
 leave:
        free_message(commit, &msg);