Skip to content

Commit 9240bed

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a1c7576 commit 9240bed

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sequencer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ static char **read_author_script(void)
484484
* author metadata.
485485
*/
486486
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)
488488
{
489489
char **env = NULL;
490490
struct argv_array array;
@@ -513,6 +513,8 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
513513
argv_array_push(&array, "commit");
514514
argv_array_push(&array, "-n");
515515

516+
if (amend)
517+
argv_array_push(&array, "--amend");
516518
if (opts->gpg_sign)
517519
argv_array_pushf(&array, "-S%s", opts->gpg_sign);
518520
if (opts->signoff)
@@ -786,7 +788,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
786788
}
787789
if (!opts->no_commit)
788790
res = run_git_commit(opts->edit ? NULL : git_path_merge_msg(),
789-
opts, allow, opts->edit);
791+
opts, allow, opts->edit, 0);
790792

791793
leave:
792794
free_message(commit, &msg);

0 commit comments

Comments
 (0)