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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Oct 21, 2016 at 14:25 UTC
0009426d6721a0356d41811aa34b4ac7f278a76e
1 file changed
+7
-3
sequencer.c
+7
-3
@@ -484,7 +484,8 @@ 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, int amend)
487
+ int allow_empty, int edit, int amend,
488
+ int cleanup_commit_message)
489
{
490
char **env = NULL;
491
struct argv_array array;
@@ -521,9 +522,12 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
522
argv_array_push(&array, "-s");
523
if (defmsg)
524
argv_array_pushl(&array, "-F", defmsg, NULL);
525
+ if (cleanup_commit_message)
526
+ argv_array_push(&array, "--cleanup=strip");
527
if (edit)
528
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 &&
531
git_config_get_value("commit.cleanup", &value))
532
argv_array_push(&array, "--cleanup=verbatim");
533
@@ -788,7 +792,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
792
}
793
if (!opts->no_commit)
794
res = run_git_commit(opts->edit ? NULL : git_path_merge_msg(),
791
- opts, allow, opts->edit, 0);
795
+ opts, allow, opts->edit, 0, 0);
796
797
leave:
798
free_message(commit, &msg);