Skip to content

Commit e1ca6cd

Browse files
committed
sequencer: support amending commits
This teaches the sequencer_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>
1 parent fbb71fb commit e1ca6cd

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

sequencer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static char **read_author_script()
468468
* (except, of course, while running an interactive rebase).
469469
*/
470470
int sequencer_commit(const char *defmsg, struct replay_opts *opts,
471-
int allow_empty, int edit)
471+
int allow_empty, int edit, int amend)
472472
{
473473
char **env = NULL;
474474
struct argv_array array;
@@ -498,6 +498,8 @@ int sequencer_commit(const char *defmsg, struct replay_opts *opts,
498498
argv_array_push(&array, "commit");
499499
argv_array_push(&array, "-n");
500500

501+
if (amend)
502+
argv_array_push(&array, "--amend");
501503
if (opts->gpg_sign)
502504
argv_array_pushf(&array, "-S%s", opts->gpg_sign);
503505
if (opts->signoff)
@@ -778,7 +780,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
778780
}
779781
if (!opts->no_commit)
780782
res = sequencer_commit(git_path_merge_msg(), opts, allow,
781-
opts->edit);
783+
opts->edit, 0);
782784

783785
leave:
784786
free_message(commit, &msg);

sequencer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int sequencer_rollback(struct replay_opts *opts);
4545
int sequencer_remove_state(struct replay_opts *opts);
4646

4747
int sequencer_commit(const char *defmsg, struct replay_opts *opts,
48-
int allow_empty, int edit);
48+
int allow_empty, int edit, int amend);
4949

5050
extern const char sign_off_header[];
5151

0 commit comments

Comments
 (0)