Skip to content

Commit 0009426

Browse files
dschogitster
authored andcommitted
sequencer: support cleaning up commit messages
The run_git_commit() function already knows how to amend commits, and with this new option, it can also clean up commit messages (i.e. strip out commented lines). This is needed to implement rebase -i's 'fixup' and 'squash' commands as sequencer commands. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9240bed commit 0009426

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sequencer.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ 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, int amend)
487+
int allow_empty, int edit, int amend,
488+
int cleanup_commit_message)
488489
{
489490
char **env = NULL;
490491
struct argv_array array;
@@ -521,9 +522,12 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
521522
argv_array_push(&array, "-s");
522523
if (defmsg)
523524
argv_array_pushl(&array, "-F", defmsg, NULL);
525+
if (cleanup_commit_message)
526+
argv_array_push(&array, "--cleanup=strip");
524527
if (edit)
525528
argv_array_push(&array, "-e");
526-
else if (!opts->signoff && !opts->record_origin &&
529+
else if (!cleanup_commit_message &&
530+
!opts->signoff && !opts->record_origin &&
527531
git_config_get_value("commit.cleanup", &value))
528532
argv_array_push(&array, "--cleanup=verbatim");
529533

@@ -788,7 +792,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
788792
}
789793
if (!opts->no_commit)
790794
res = run_git_commit(opts->edit ? NULL : git_path_merge_msg(),
791-
opts, allow, opts->edit, 0);
795+
opts, allow, opts->edit, 0, 0);
792796

793797
leave:
794798
free_message(commit, &msg);

0 commit comments

Comments
 (0)