sequencer: use run_command() directly
Instead of using the convenience function run_command_v_opt_cd_env(), we now use the run_command() function. The former function is simply a wrapper of the latter, trying to make it more convenient to use. However, we already have to construct the argv and the env parameters, and we will need even finer control e.g. over the output of the command, so let's just stop using the convenience function. Based on patches and suggestions by Johannes Sixt and Jeff King. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
a2a20b0d5c
commit
07d968ef14
36
sequencer.c
36
sequencer.c
@ -604,12 +604,13 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
|
|||||||
int allow_empty, int edit, int amend,
|
int allow_empty, int edit, int amend,
|
||||||
int cleanup_commit_message)
|
int cleanup_commit_message)
|
||||||
{
|
{
|
||||||
struct argv_array env = ARGV_ARRAY_INIT, array;
|
struct child_process cmd = CHILD_PROCESS_INIT;
|
||||||
int rc;
|
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
|
cmd.git_cmd = 1;
|
||||||
|
|
||||||
if (is_rebase_i(opts)) {
|
if (is_rebase_i(opts)) {
|
||||||
if (!read_env_script(&env)) {
|
if (read_env_script(&cmd.env_array)) {
|
||||||
const char *gpg_opt = gpg_sign_opt_quoted(opts);
|
const char *gpg_opt = gpg_sign_opt_quoted(opts);
|
||||||
|
|
||||||
return error(_(staged_changes_advice),
|
return error(_(staged_changes_advice),
|
||||||
@ -617,39 +618,34 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argv_array_init(&array);
|
argv_array_push(&cmd.args, "commit");
|
||||||
argv_array_push(&array, "commit");
|
argv_array_push(&cmd.args, "-n");
|
||||||
argv_array_push(&array, "-n");
|
|
||||||
|
|
||||||
if (amend)
|
if (amend)
|
||||||
argv_array_push(&array, "--amend");
|
argv_array_push(&cmd.args, "--amend");
|
||||||
if (opts->gpg_sign)
|
if (opts->gpg_sign)
|
||||||
argv_array_pushf(&array, "-S%s", opts->gpg_sign);
|
argv_array_pushf(&cmd.args, "-S%s", opts->gpg_sign);
|
||||||
if (opts->signoff)
|
if (opts->signoff)
|
||||||
argv_array_push(&array, "-s");
|
argv_array_push(&cmd.args, "-s");
|
||||||
if (defmsg)
|
if (defmsg)
|
||||||
argv_array_pushl(&array, "-F", defmsg, NULL);
|
argv_array_pushl(&cmd.args, "-F", defmsg, NULL);
|
||||||
if (cleanup_commit_message)
|
if (cleanup_commit_message)
|
||||||
argv_array_push(&array, "--cleanup=strip");
|
argv_array_push(&cmd.args, "--cleanup=strip");
|
||||||
if (edit)
|
if (edit)
|
||||||
argv_array_push(&array, "-e");
|
argv_array_push(&cmd.args, "-e");
|
||||||
else if (!cleanup_commit_message &&
|
else if (!cleanup_commit_message &&
|
||||||
!opts->signoff && !opts->record_origin &&
|
!opts->signoff && !opts->record_origin &&
|
||||||
git_config_get_value("commit.cleanup", &value))
|
git_config_get_value("commit.cleanup", &value))
|
||||||
argv_array_push(&array, "--cleanup=verbatim");
|
argv_array_push(&cmd.args, "--cleanup=verbatim");
|
||||||
|
|
||||||
if (allow_empty)
|
if (allow_empty)
|
||||||
argv_array_push(&array, "--allow-empty");
|
argv_array_push(&cmd.args, "--allow-empty");
|
||||||
|
|
||||||
if (opts->allow_empty_message)
|
if (opts->allow_empty_message)
|
||||||
argv_array_push(&array, "--allow-empty-message");
|
argv_array_push(&cmd.args, "--allow-empty-message");
|
||||||
|
|
||||||
rc = run_command_v_opt_cd_env(array.argv, RUN_GIT_CMD, NULL,
|
|
||||||
(const char *const *)env.argv);
|
|
||||||
argv_array_clear(&array);
|
|
||||||
argv_array_clear(&env);
|
|
||||||
|
|
||||||
return rc;
|
return run_command(&cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int is_original_commit_empty(struct commit *commit)
|
static int is_original_commit_empty(struct commit *commit)
|
||||||
|
Loading…
Reference in New Issue
Block a user