From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.5 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id BB4B51F609 for ; Wed, 28 Nov 2018 15:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728552AbeK2CVE (ORCPT ); Wed, 28 Nov 2018 21:21:04 -0500 Received: from mout.gmx.net ([212.227.15.18]:57805 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727872AbeK2CVE (ORCPT ); Wed, 28 Nov 2018 21:21:04 -0500 Received: from [192.168.0.129] ([37.201.193.149]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M3AWN-1fZn06387D-00sxYT; Wed, 28 Nov 2018 16:19:01 +0100 Date: Wed, 28 Nov 2018 16:19:02 +0100 (STD) From: Johannes Schindelin X-X-Sender: virtualbox@gitforwindows.org To: Paul Morelle cc: Git Users Subject: Re: [PATCH] rebase -i: introduce the 'test' command In-Reply-To: <3fb5a7ff-a63a-6fac-1456-4dbc9135d088@gmail.com> Message-ID: References: <3fb5a7ff-a63a-6fac-1456-4dbc9135d088@gmail.com> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K1:fyrBqD2/LvWyhLfaHIV6SCXs9Snwng4FbBZVtS7CANTfn7x4epx NNQs5p/V7rQXBXRupjHAEagfq35hf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Hh7MQ8 /o6vBXwH10VOAKu73876px8890A3u+MVAVmYzuPslp/lamQOhqC+fNxOMGRdzlZhvZuYt4X+F YCrcTZSCPnA== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Paul, On Wed, 28 Nov 2018, Paul Morelle wrote: > The 'exec' command can be used to run tests on a set of commits, > interrupting on failing commits to let the user fix the tests. > > However, the 'exec' line has been consumed, so it won't be ran again by > 'git rebase --continue' is ran, even if the tests weren't fixed. > > This commit introduces a new command 'test' equivalent to 'exec', except > that it is automatically rescheduled in the todo list if it fails. > > Signed-off-by: Paul Morelle Would it not make more sense to add a command-line option (and a config setting) to re-schedule failed `exec` commands? Like so: -- snip -- diff --git a/builtin/rebase--interactive.c b/builtin/rebase--interactive.c index a2ab68ed0632..a9ab009fdbca 100644 --- a/builtin/rebase--interactive.c +++ b/builtin/rebase--interactive.c @@ -192,6 +192,8 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix) OPT_STRING(0, "onto-name", &onto_name, N_("onto-name"), N_("onto name")), OPT_STRING(0, "cmd", &cmd, N_("cmd"), N_("the command to run")), OPT_RERERE_AUTOUPDATE(&opts.allow_rerere_auto), + OPT_BOOL(0, "reschedule-failed-exec", &opts.reschedule_failed_exec, + N_("automatically re-schedule any `exec` that fails")), OPT_END() }; diff --git a/builtin/rebase.c b/builtin/rebase.c index 5b3e5baec8a0..700cbc4e150e 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -104,6 +104,7 @@ struct rebase_options { int rebase_merges, rebase_cousins; char *strategy, *strategy_opts; struct strbuf git_format_patch_opt; + int reschedule_failed_exec; }; static int is_interactive(struct rebase_options *opts) @@ -415,6 +416,8 @@ static int run_specific_rebase(struct rebase_options *opts) argv_array_push(&child.args, opts->gpg_sign_opt); if (opts->signoff) argv_array_push(&child.args, "--signoff"); + if (opts->reschedule_failed_exec) + argv_array_push(&child.args, "--reschedule-failed-exec"); status = run_command(&child); goto finished_rebase; @@ -903,6 +906,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) "strategy")), OPT_BOOL(0, "root", &options.root, N_("rebase all reachable commits up to the root(s)")), + OPT_BOOL(0, "reschedule-failed-exec", + &options.reschedule_failed_exec, + N_("automatically re-schedule any `exec` that fails")), OPT_END(), }; int i; @@ -1195,6 +1201,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) break; } + if (options.reschedule_failed_exec && !is_interactive(&options)) + die(_("--reschedule-failed-exec requires an interactive rebase")); + if (options.git_am_opts.argc) { /* all am options except -q are compatible only with --am */ for (i = options.git_am_opts.argc - 1; i >= 0; i--) diff --git a/sequencer.c b/sequencer.c index e1a4dd15f1a8..69bee63e116f 100644 --- a/sequencer.c +++ b/sequencer.c @@ -158,6 +158,7 @@ static GIT_PATH_FUNC(rebase_path_strategy, "rebase-merge/strategy") static GIT_PATH_FUNC(rebase_path_strategy_opts, "rebase-merge/strategy_opts") static GIT_PATH_FUNC(rebase_path_allow_rerere_autoupdate, "rebase-merge/allow_rerere_autoupdate") static GIT_PATH_FUNC(rebase_path_quiet, "rebase-merge/quiet") +static GIT_PATH_FUNC(rebase_path_reschedule_failed_exec, "rebase-merge/reschedule-failed-exec") static int git_sequencer_config(const char *k, const char *v, void *cb) { @@ -2362,6 +2363,9 @@ static int read_populate_opts(struct replay_opts *opts) opts->signoff = 1; } + if (file_exists(rebase_path_reschedule_failed_exec())) + opts->reschedule_failed_exec = 1; + read_strategy_opts(opts, &buf); strbuf_release(&buf); @@ -2443,6 +2447,8 @@ int write_basic_state(struct replay_opts *opts, const char *head_name, write_file(rebase_path_gpg_sign_opt(), "-S%s\n", opts->gpg_sign); if (opts->signoff) write_file(rebase_path_signoff(), "--signoff\n"); + if (opts->reschedule_failed_exec) + write_file(rebase_path_reschedule_failed_exec(), "%s", ""); return 0; } @@ -3586,9 +3592,10 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts) *end_of_arg = saved; /* Reread the todo file if it has changed. */ - if (res) - ; /* fall through */ - else if (stat(get_todo_path(opts), &st)) + if (res) { + if (opts->reschedule_failed_exec) + reschedule = 1; + } else if (stat(get_todo_path(opts), &st)) res = error_errno(_("could not stat '%s'"), get_todo_path(opts)); else if (match_stat_data(&todo_list->stat, &st)) { diff --git a/sequencer.h b/sequencer.h index 5071a73563f1..1f865dae2618 100644 --- a/sequencer.h +++ b/sequencer.h @@ -39,6 +39,7 @@ struct replay_opts { int allow_empty_message; int keep_redundant_commits; int verbose; + int reschedule_failed_exec; int mainline; -- snap -- That would avoid your having to add a `--test` option accompanying the `--exec` option (which is missing from your patch). Ciao, Johannes > --- > Documentation/git-rebase.txt | 9 ++++++--- > rebase-interactive.c | 1 + > sequencer.c | 23 +++++++++++++++-------- > t/lib-rebase.sh | 4 +++- > t/t3404-rebase-interactive.sh | 16 ++++++++++++++++ > 5 files changed, 41 insertions(+), 12 deletions(-) > > diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt > index 80793bad8..c8f565637 100644 > --- a/Documentation/git-rebase.txt > +++ b/Documentation/git-rebase.txt > @@ -693,8 +693,8 @@ $ git rebase -i -p --onto Q O > Reordering and editing commits usually creates untested intermediate > steps. You may want to check that your history editing did not break > anything by running a test, or at least recompiling at intermediate > -points in history by using the "exec" command (shortcut "x"). You may > -do so by creating a todo list like this one: > +points in history by using the "exec" command (shortcut "x") or the > +"test" command. You may do so by creating a todo list like this one: > ------------------------------------------- > pick deadbee Implement feature XXX > @@ -702,7 +702,7 @@ fixup f1a5c00 Fix to feature XXX > exec make > pick c0ffeee The oneline of the next commit > edit deadbab The oneline of the commit after > -exec cd subdir; make test > +test cd subdir; make test > ... > ------------------------------------------- > @@ -715,6 +715,9 @@ in `$SHELL`, or the default shell if `$SHELL` is > not set), so you can > use shell features (like "cd", ">", ";" ...). The command is run from > the root of the working tree. > +The "test" command does the same, but will remain in the todo list as > +the next command, until it succeeds. > + > ---------------------------------- > $ git rebase -i --exec "make test" > ---------------------------------- > diff --git a/rebase-interactive.c b/rebase-interactive.c > index 78f3263fc..4a408661d 100644 > --- a/rebase-interactive.c > +++ b/rebase-interactive.c > @@ -14,6 +14,7 @@ void append_todo_help(unsigned edit_todo, unsigned > keep_empty, > "s, squash = use commit, but meld into previous commit\n" > "f, fixup = like \"squash\", but discard this commit's log > message\n" > "x, exec = run command (the rest of the line) using shell\n" > +" test = same as exec command, but keep it in TODO if it > fails\n" > "b, break = stop here (continue rebase later with 'git rebase > --continue')\n" > "d, drop = remove commit\n" > "l, label