sequencer: support amending commits

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>

Johannes Schindelin committed Oct 21, 2016 at 14:25 UTC 9240beda621dc0b4eec66f5ad9a8258c0f614e4c
1 file changed +4 -2
sequencer.c
+4 -2
@@ -484,7 +484,7 @@ static char **read_author_script(void)
484 * author metadata.
485 */
486 static int run_git_commit(const char *defmsg, struct replay_opts *opts,
487 - int allow_empty, int edit)
487 + int allow_empty, int edit, int amend)
488 {
489 char **env = NULL;
490 struct argv_array array;
@@ -513,6 +513,8 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
513 argv_array_push(&array, "commit");
514 argv_array_push(&array, "-n");
515
516 + if (amend)
517 + argv_array_push(&array, "--amend");
518 if (opts->gpg_sign)
519 argv_array_pushf(&array, "-S%s", opts->gpg_sign);
520 if (opts->signoff)
@@ -786,7 +788,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
788 }
789 if (!opts->no_commit)
790 res = run_git_commit(opts->edit ? NULL : git_path_merge_msg(),
789 - opts, allow, opts->edit);
791 + opts, allow, opts->edit, 0);
792
793 leave:
794 free_message(commit, &msg);