From 4344341ebaa6e41a30656d6489ba377c53a24773 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 4 Mar 2016 16:13:26 +0100 Subject: [PATCH] sequencer: allow editing the commit message on a case-by-case basis In the upcoming commits, we will implement more and more of rebase -i's functionality. One particular feature of the commands to come is that some of them allow editing the commit message while others don't, i.e. we cannot define in the replay_opts whether the commit message should be edited or not. Let's add a new parameter to the sequencer_commit() function. Previously, it was the duty of the caller to ensure that the opts->edit setting indicates whether to let the user edit the commit message or not, indicating that it is an "all or nothing" setting, i.e. that the sequencer wants to let the user edit *all* commit message, or none at all. In the upcoming rebase -i mode, it will depend on the particular command that is currently executed, though. Signed-off-by: Johannes Schindelin --- sequencer.c | 6 +++--- sequencer.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sequencer.c b/sequencer.c index bf02565b4c..6e9732c5a5 100644 --- a/sequencer.c +++ b/sequencer.c @@ -485,7 +485,7 @@ static char **read_author_script(void) * author metadata. */ int sequencer_commit(const char *defmsg, struct replay_opts *opts, - int allow_empty) + int allow_empty, int edit) { char **env = NULL; struct argv_array array; @@ -520,7 +520,7 @@ int sequencer_commit(const char *defmsg, struct replay_opts *opts, argv_array_push(&array, "-s"); if (defmsg) argv_array_pushl(&array, "-F", defmsg, NULL); - if (opts->edit) + if (edit) argv_array_push(&array, "-e"); else if (!opts->signoff && !opts->record_origin && git_config_get_value("commit.cleanup", &value)) @@ -786,7 +786,7 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, } if (!opts->no_commit) res = sequencer_commit(opts->edit ? NULL : git_path_merge_msg(), - opts, allow); + opts, allow, opts->edit); leave: free_message(commit, &msg); diff --git a/sequencer.h b/sequencer.h index 16deb6c85d..7f5222f6c2 100644 --- a/sequencer.h +++ b/sequencer.h @@ -54,7 +54,7 @@ int sequencer_rollback(struct replay_opts *opts); int sequencer_remove_state(struct replay_opts *opts); int sequencer_commit(const char *defmsg, struct replay_opts *opts, - int allow_empty); + int allow_empty, int edit); extern const char sign_off_header[];