From patchwork Mon Dec 23 18:49:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11308625 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E9DB921 for ; Mon, 23 Dec 2019 18:50:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40FE92075B for ; Mon, 23 Dec 2019 18:50:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iFLiArZw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726867AbfLWSuG (ORCPT ); Mon, 23 Dec 2019 13:50:06 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:35618 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbfLWSuF (ORCPT ); Mon, 23 Dec 2019 13:50:05 -0500 Received: by mail-ed1-f67.google.com with SMTP id f8so16144899edv.2 for ; Mon, 23 Dec 2019 10:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ptSnllA63IKvqrQACoPMqSba5exbclYEtYgXCD/nQlI=; b=iFLiArZwgokWUd346sl292OjlAe0xiVGWmYjkuad15BflA0r0VAHjWW045m2FNlf04 DjcSwjmgnb+Dd0oqrIQjrQ8QvbydJkBMXPfucbdqENNHnbZRbsSiDljIcsrBoRyWrTDe +1Ed/H8iLpYT1bwcpQo9M734W65qVARpNICOXissDuc0un0V59fyAbJnJxqid1498iYS VepKcX4k2XbCpVVKLXiNCzsqOVlPZY3+bxmnGHLu8bkaLy9cJHmHUPF/7v7qdTMfRiqk oAaCBrXk1kZU5kpZebIh2ITA8NiLE8QHAIgRR1zpjnC4FUIh3k4SWH2CmDs+3Usp3cj7 IVjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ptSnllA63IKvqrQACoPMqSba5exbclYEtYgXCD/nQlI=; b=dtr544DBtotJu2+54MrtWEuwBKyzyhqdGU3HysL65fCr0i9LHquUF+jnwVuGzOzmS+ fUamrO2P3bFZAlJ7qWWq/hwGLMtBgUFWAwumXsYIBJSeYAyXE3gHDbhoVX36dSOSjSXW C1MUs5rutMCVgQgL3NE2Ou02TgO66kGudWJvxsoTwZXem1OktsgfFmrGBpHiIi+GiDV4 U+zWwJYd4yvMyiRI6wpjMKMvSx2qNFAXNJhxyBgIgo+FrsZB6Jo4cW9DcGO6x/5nAgr2 pI+kdG+OHGC5z2N45X4soMBAmhj3ZrFmyETGSTeNtkn7P4vGr24c4cRpO03m75fujvQ+ iGmw== X-Gm-Message-State: APjAAAVupOWpGott2OYGsPaCoWCqG56CxF4ktUuoRJtsq1dH0pzjirWI zjzoCq9purYeisBOfQG62JyBN/2k X-Google-Smtp-Source: APXvYqzLSDuMtMr4oswMSQJuEF7OUgmB7Q7Rf51mRylHIXRYQwuhaC06D2ethqQs2dogiezOIPU7Tg== X-Received: by 2002:a17:906:3601:: with SMTP id q1mr9103371ejb.276.1577127002151; Mon, 23 Dec 2019 10:50:02 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ck28sm2394372edb.45.2019.12.23.10.50.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2019 10:50:01 -0800 (PST) Message-Id: <1c2b77e94d63f86590ca934855066eca278f576e.1577127000.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 23 Dec 2019 18:49:45 +0000 Subject: [PATCH v2 01/15] rebase: extend the options for handling of empty commits Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, phillip.wood@dunelm.org.uk, liu.denton@gmail.com, gitster@pobox.com, plroskin@gmail.com, alban.gruin@gmail.com, szeder.dev@gmail.com, Junio C Hamano , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren Extend the interactive machinery with the ability to handle the full spread of options for how to handle commits that either start or become empty (by "become empty" I mean the changes in a commit are a subset of changes that exist upstream, so the net effect of applying the commit is no changes). Introduce a new command line flag for selecting the desired behavior: --empty={drop,keep,ask} with the definitions: drop: drop empty commits keep: keep empty commits ask: provide the user a chance to interact and pick what to do with empty commits on a case-by-case basis Note that traditionally, am-based rebases have always dropped commits that either started or became empty, while interactive-based rebases have defaulted to ask (and provided an option to keep commits that started empty). This difference made sense since users of an am-based rebase just wanted to quickly batch apply a sequence of commits, while users editing a todo list will likely want the chance to interact and handle unusual cases on a case-by-case basis. However, not all rebases using the interactive machinery are explicitly interactive anymore. In particular --merge was always meant to behave more like --am: just rebase a batch of commits without popping up a todo list. If the --empty flag is not specified, pick defaults as follows: explicitly interactive: ask --exec: keep (exec is about checking existing commits, and often used without actually changing the base. Thus the expectation is that the user doesn't necessarily want anything to change; they just want to test). otherwise: drop Also, this commit makes --keep-empty just imply --empty=keep, and hides it from help so that we aren't confusing users with different ways to do the same thing. (I could have added a --drop-empty flag, but then that invites users to specify both --keep-empty and --drop-empty and we have to add sanity checking around that; it seems cleaner to have a single multi-valued option.) This actually fixes --keep-empty too; previously, it only meant to sometimes keep empty commits, in particular commits which started empty would be kept. But it would still error out and ask the user what to do with commits that became empty. Now it keeps empty commits, as instructed. Signed-off-by: Elijah Newren --- Documentation/git-rebase.txt | 35 ++++++------ builtin/rebase.c | 83 +++++++++++++++++++++++++--- rebase-interactive.c | 4 +- rebase-interactive.h | 2 +- sequencer.c | 74 +++++++++++++++++++------ sequencer.h | 6 ++- t/t3421-rebase-topology-linear.sh | 4 +- t/t3424-rebase-empty.sh | 89 +++++++++++++++++++++++++++++++ t/t3427-rebase-subtree.sh | 16 +++--- 9 files changed, 263 insertions(+), 50 deletions(-) create mode 100755 t/t3424-rebase-empty.sh diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 1d0e2d27cc..ff32ca1080 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -258,9 +258,25 @@ See also INCOMPATIBLE OPTIONS below. original branch. The index and working tree are also left unchanged as a result. +--empty={drop,keep,ask}:: + How to handle commits that become empty (because they contain a + subset of already upstream changes) or start empty. With drop + (the default), commits that start or become empty are dropped. + With keep (implied by --exec), such commits are kept. With ask + (implied by --interactive), the rebase will halt when an empty + commit is applied allowing you to choose whether to drop it or + commit it. Also with ask, if the rebase is interactive then + commits which start empty will be commented out in the todo + action list (giving you a chance to uncomment). ++ +Note that this has no effect on commits which are already upstream (as +can be checked via `git log --cherry-mark ...`), which are always +dropped by rebase. ++ +See also INCOMPATIBLE OPTIONS below. + --keep-empty:: - Keep the commits that do not change anything from its - parents in the result. + Deprecated alias for what is now known as --empty=keep. + See also INCOMPATIBLE OPTIONS below. @@ -569,6 +585,7 @@ are incompatible with the following options: * --interactive * --exec * --keep-empty + * --empty= * --edit-todo * --root when used in combination with --onto @@ -580,6 +597,7 @@ In addition, the following pairs of options are incompatible: * --preserve-merges and --ignore-whitespace * --preserve-merges and --committer-date-is-author-date * --preserve-merges and --ignore-date + * --preserve-merges and --empty= * --keep-base and --onto * --keep-base and --root @@ -588,19 +606,6 @@ BEHAVIORAL DIFFERENCES There are some subtle differences how the backends behave. -Empty commits -~~~~~~~~~~~~~ - -The am backend drops any "empty" commits, regardless of whether the -commit started empty (had no changes relative to its parent to -start with) or ended empty (all changes were already applied -upstream in other commits). - -The interactive backend drops commits by default that -started empty and halts if it hits a commit that ended up empty. -The `--keep-empty` option exists for the interactive backend to allow -it to keep commits that started empty. - Directory rename detection ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/builtin/rebase.c b/builtin/rebase.c index ddf33bc9d4..6903249307 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -50,8 +50,16 @@ enum rebase_type { REBASE_PRESERVE_MERGES }; +enum empty_type { + EMPTY_UNSPECIFIED = -1, + EMPTY_DROP, + EMPTY_KEEP, + EMPTY_ASK +}; + struct rebase_options { enum rebase_type type; + enum empty_type empty; const char *state_dir; struct commit *upstream; const char *upstream_name; @@ -77,7 +85,6 @@ struct rebase_options { const char *action; int signoff; int allow_rerere_autoupdate; - int keep_empty; int autosquash; int ignore_whitespace; char *gpg_sign_opt; @@ -95,6 +102,7 @@ struct rebase_options { #define REBASE_OPTIONS_INIT { \ .type = REBASE_UNSPECIFIED, \ + .empty = EMPTY_UNSPECIFIED, \ .flags = REBASE_NO_QUIET, \ .git_am_opts = ARGV_ARRAY_INIT, \ .git_format_patch_opt = STRBUF_INIT \ @@ -114,6 +122,10 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts) replay.allow_rerere_auto = opts->allow_rerere_autoupdate; replay.allow_empty = 1; replay.allow_empty_message = opts->allow_empty_message; + replay.drop_redundant_commits = (opts->empty == EMPTY_DROP); + replay.keep_redundant_commits = (opts->empty == EMPTY_KEEP); + replay.ask_on_initially_empty = (opts->empty == EMPTY_ASK && + !(opts->flags & REBASE_INTERACTIVE_EXPLICIT)); replay.verbose = opts->flags & REBASE_VERBOSE; replay.reschedule_failed_exec = opts->reschedule_failed_exec; replay.committer_date_is_author_date = @@ -389,7 +401,10 @@ static int run_rebase_interactive(struct rebase_options *opts, git_config_get_bool("rebase.abbreviatecommands", &abbreviate_commands); - flags |= opts->keep_empty ? TODO_LIST_KEEP_EMPTY : 0; + flags |= (opts->empty == EMPTY_DROP) ? TODO_LIST_DROP_EMPTY : 0; + flags |= (opts->empty == EMPTY_ASK && + opts->flags & REBASE_INTERACTIVE_EXPLICIT) ? + TODO_LIST_ASK_EMPTY : 0; flags |= abbreviate_commands ? TODO_LIST_ABBREVIATE_CMDS : 0; flags |= opts->rebase_merges ? TODO_LIST_REBASE_MERGES : 0; flags |= opts->rebase_cousins > 0 ? TODO_LIST_REBASE_COUSINS : 0; @@ -453,6 +468,19 @@ static int run_rebase_interactive(struct rebase_options *opts, return ret; } +static int parse_opt_keep_empty(const struct option *opt, const char *arg, + int unset) +{ + struct rebase_options *opts = opt->value; + + BUG_ON_OPT_NEG(unset); + BUG_ON_OPT_ARG(arg); + + opts->empty = EMPTY_KEEP; + opts->type = REBASE_INTERACTIVE; + return 0; +} + static const char * const builtin_rebase_interactive_usage[] = { N_("git rebase--interactive []"), NULL @@ -466,7 +494,10 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix) struct option options[] = { OPT_NEGBIT(0, "ff", &opts.flags, N_("allow fast-forward"), REBASE_FORCE), - OPT_BOOL(0, "keep-empty", &opts.keep_empty, N_("keep empty commits")), + { OPTION_CALLBACK, 'k', "keep-empty", &options, NULL, + N_("(DEPRECATED) keep empty commits"), + PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_HIDDEN, + parse_opt_keep_empty }, OPT_BOOL(0, "allow-empty-message", &opts.allow_empty_message, N_("allow commits with empty messages")), OPT_BOOL(0, "rebase-merges", &opts.rebase_merges, N_("rebase merge commits")), @@ -1166,7 +1197,7 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action) opts->allow_rerere_autoupdate ? opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE ? "--rerere-autoupdate" : "--no-rerere-autoupdate" : ""); - add_var(&script_snippet, "keep_empty", opts->keep_empty ? "yes" : ""); + add_var(&script_snippet, "empty", opts->empty == EMPTY_KEEP ? "yes" : ""); add_var(&script_snippet, "autosquash", opts->autosquash ? "t" : ""); add_var(&script_snippet, "gpg_sign_opt", opts->gpg_sign_opt); add_var(&script_snippet, "cmd", opts->cmd); @@ -1360,6 +1391,29 @@ static int parse_opt_interactive(const struct option *opt, const char *arg, return 0; } +static enum empty_type parse_empty_value(const char *value) +{ + if (!strcasecmp(value, "drop")) + return EMPTY_DROP; + else if (!strcasecmp(value, "keep")) + return EMPTY_KEEP; + else if (!strcasecmp(value, "ask")) + return EMPTY_ASK; + + die(_("unrecognized empty type '%s'; valid values are \"drop\", \"keep\", and \"ask\"."), value); +} + +static int parse_opt_empty(const struct option *opt, const char *arg, int unset) +{ + struct rebase_options *options = opt->value; + enum empty_type value = parse_empty_value(arg); + + BUG_ON_OPT_NEG(unset); + + options->empty = value; + return 0; +} + static void NORETURN error_on_missing_default_upstream(void) { struct branch *current_branch = branch_get(NULL); @@ -1505,8 +1559,13 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) "ignoring them"), REBASE_PRESERVE_MERGES, PARSE_OPT_HIDDEN), OPT_RERERE_AUTOUPDATE(&options.allow_rerere_autoupdate), - OPT_BOOL('k', "keep-empty", &options.keep_empty, - N_("preserve empty commits during rebase")), + OPT_CALLBACK_F(0, "empty", &options, N_("{drop,keep,ask}"), + N_("how to handle empty commits"), + PARSE_OPT_NONEG, parse_opt_empty), + { OPTION_CALLBACK, 'k', "keep-empty", &options, NULL, + N_("(DEPRECATED) keep empty commits"), + PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_HIDDEN, + parse_opt_keep_empty }, OPT_BOOL(0, "autosquash", &options.autosquash, N_("move commits that begin with " "squash!/fixup! under -i")), @@ -1770,8 +1829,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) if (!(options.flags & REBASE_NO_QUIET)) argv_array_push(&options.git_am_opts, "-q"); - if (options.keep_empty) - imply_interactive(&options, "--keep-empty"); + if (options.empty != EMPTY_UNSPECIFIED) + imply_interactive(&options, "--empty"); if (gpg_sign) { free(options.gpg_sign_opt); @@ -1856,6 +1915,14 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) break; } + if (options.empty == EMPTY_UNSPECIFIED) { + if (options.flags & REBASE_INTERACTIVE_EXPLICIT) + options.empty = EMPTY_ASK; + else if (exec.nr > 0) + options.empty = EMPTY_KEEP; + else + options.empty = EMPTY_DROP; + } if (reschedule_failed_exec > 0 && !is_interactive(&options)) die(_("--reschedule-failed-exec requires " "--exec or --interactive")); diff --git a/rebase-interactive.c b/rebase-interactive.c index aa18ae82b7..ad82bf77df 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -28,7 +28,7 @@ static enum missing_commit_check_level get_missing_commit_check_level(void) return MISSING_COMMIT_CHECK_IGNORE; } -void append_todo_help(unsigned keep_empty, int command_count, +void append_todo_help(unsigned no_ask_empty, int command_count, const char *shortrevisions, const char *shortonto, struct strbuf *buf) { @@ -81,7 +81,7 @@ void append_todo_help(unsigned keep_empty, int command_count, strbuf_add_commented_lines(buf, msg, strlen(msg)); - if (!keep_empty) { + if (!no_ask_empty) { msg = _("Note that empty commits are commented out"); strbuf_add_commented_lines(buf, msg, strlen(msg)); } diff --git a/rebase-interactive.h b/rebase-interactive.h index 44dbb06311..f531e00ba7 100644 --- a/rebase-interactive.h +++ b/rebase-interactive.h @@ -5,7 +5,7 @@ struct strbuf; struct repository; struct todo_list; -void append_todo_help(unsigned keep_empty, int command_count, +void append_todo_help(unsigned no_ask_empty, int command_count, const char *shortrevisions, const char *shortonto, struct strbuf *buf); int edit_todo_list(struct repository *r, struct todo_list *todo_list, diff --git a/sequencer.c b/sequencer.c index 763ccbbc45..d2c11f34b7 100644 --- a/sequencer.c +++ b/sequencer.c @@ -160,6 +160,9 @@ 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_reschedule_failed_exec, "rebase-merge/reschedule-failed-exec") +static GIT_PATH_FUNC(rebase_path_drop_redundant_commits, "rebase-merge/drop_redundant_commits") +static GIT_PATH_FUNC(rebase_path_keep_redundant_commits, "rebase-merge/keep_redundant_commits") +static GIT_PATH_FUNC(rebase_path_ask_on_initially_empty, "rebase-merge/ask_on_initially_empty") static int git_sequencer_config(const char *k, const char *v, void *cb) { @@ -1623,7 +1626,7 @@ static int allow_empty(struct repository *r, empty_commit = is_original_commit_empty(commit); if (empty_commit < 0) return empty_commit; - if (!empty_commit) + if (!empty_commit || opts->ask_on_initially_empty) return 0; else return 1; @@ -1837,7 +1840,7 @@ static int do_pick_commit(struct repository *r, char *author = NULL; struct commit_message msg = { NULL, NULL, NULL, NULL }; struct strbuf msgbuf = STRBUF_INIT; - int res, unborn = 0, reword = 0, allow; + int res, unborn = 0, reword = 0, allow, drop_commit; if (opts->no_commit) { /* @@ -2042,13 +2045,20 @@ static int do_pick_commit(struct repository *r, goto leave; } - allow = allow_empty(r, opts, commit); - if (allow < 0) { - res = allow; - goto leave; - } else if (allow) - flags |= ALLOW_EMPTY; - if (!opts->no_commit) { + drop_commit = 0; + if (opts->drop_redundant_commits && is_index_unchanged(r)) { + drop_commit = 1; + fprintf(stderr, _("No changes -- Patch already applied.")); + } else { + allow = allow_empty(r, opts, commit); + if (allow < 0) { + res = allow; + goto leave; + } else if (allow) { + flags |= ALLOW_EMPTY; + } + } + if (!opts->no_commit && !drop_commit) { if (author || command == TODO_REVERT || (flags & AMEND_MSG)) res = do_commit(r, msg_file, author, opts, flags); else @@ -2501,9 +2511,15 @@ static int populate_opts_cb(const char *key, const char *value, void *data) else if (!strcmp(key, "options.allow-empty-message")) opts->allow_empty_message = git_config_bool_or_int(key, value, &error_flag); + else if (!strcmp(key, "options.drop-redundant-commits")) + opts->drop_redundant_commits = + git_config_bool_or_int(key, value, &error_flag); else if (!strcmp(key, "options.keep-redundant-commits")) opts->keep_redundant_commits = git_config_bool_or_int(key, value, &error_flag); + else if (!strcmp(key, "options.ask_on_initially_empty")) + opts->ask_on_initially_empty = + git_config_bool_or_int(key, value, &error_flag); else if (!strcmp(key, "options.signoff")) opts->signoff = git_config_bool_or_int(key, value, &error_flag); else if (!strcmp(key, "options.record-origin")) @@ -2612,6 +2628,15 @@ static int read_populate_opts(struct replay_opts *opts) if (file_exists(rebase_path_reschedule_failed_exec())) opts->reschedule_failed_exec = 1; + if (file_exists(rebase_path_drop_redundant_commits())) + opts->drop_redundant_commits = 1; + + if (file_exists(rebase_path_keep_redundant_commits())) + opts->keep_redundant_commits = 1; + + if (file_exists(rebase_path_ask_on_initially_empty())) + opts->ask_on_initially_empty = 1; + read_strategy_opts(opts, &buf); strbuf_release(&buf); @@ -2695,6 +2720,12 @@ int write_basic_state(struct replay_opts *opts, const char *head_name, write_file(rebase_path_cdate_is_adate(), "%s", ""); if (opts->ignore_date) write_file(rebase_path_ignore_date(), "%s", ""); + if (opts->drop_redundant_commits) + write_file(rebase_path_drop_redundant_commits(), "%s", ""); + if (opts->keep_redundant_commits) + write_file(rebase_path_keep_redundant_commits(), "%s", ""); + if (opts->ask_on_initially_empty) + write_file(rebase_path_ask_on_initially_empty(), "%s", ""); if (opts->reschedule_failed_exec) write_file(rebase_path_reschedule_failed_exec(), "%s", ""); @@ -3033,9 +3064,15 @@ static int save_opts(struct replay_opts *opts) if (opts->allow_empty_message) res |= git_config_set_in_file_gently(opts_file, "options.allow-empty-message", "true"); + if (opts->drop_redundant_commits) + res |= git_config_set_in_file_gently(opts_file, + "options.drop-redundant-commits", "true"); if (opts->keep_redundant_commits) res |= git_config_set_in_file_gently(opts_file, "options.keep-redundant-commits", "true"); + if (opts->ask_on_initially_empty) + res |= git_config_set_in_file_gently(opts_file, + "options.ask_on_initially_empty", "true"); if (opts->signoff) res |= git_config_set_in_file_gently(opts_file, "options.signoff", "true"); @@ -4691,7 +4728,8 @@ static int make_script_with_merges(struct pretty_print_context *pp, struct rev_info *revs, struct strbuf *out, unsigned flags) { - int keep_empty = flags & TODO_LIST_KEEP_EMPTY; + int drop_empty = flags & TODO_LIST_DROP_EMPTY; + int ask_empty = flags & TODO_LIST_ASK_EMPTY; int rebase_cousins = flags & TODO_LIST_REBASE_COUSINS; int root_with_onto = flags & TODO_LIST_ROOT_WITH_ONTO; struct strbuf buf = STRBUF_INIT, oneline = STRBUF_INIT; @@ -4746,6 +4784,8 @@ static int make_script_with_merges(struct pretty_print_context *pp, is_empty = is_original_commit_empty(commit); if (!is_empty && (commit->object.flags & PATCHSAME)) continue; + if (is_empty && drop_empty) + continue; strbuf_reset(&oneline); pretty_print_commit(pp, commit, &oneline); @@ -4754,7 +4794,7 @@ static int make_script_with_merges(struct pretty_print_context *pp, if (!to_merge) { /* non-merge commit: easy case */ strbuf_reset(&buf); - if (!keep_empty && is_empty) + if (is_empty && ask_empty) strbuf_addf(&buf, "%c ", comment_line_char); strbuf_addf(&buf, "%s %s %s", cmd_pick, oid_to_hex(&commit->object.oid), @@ -4922,7 +4962,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc, struct pretty_print_context pp = {0}; struct rev_info revs; struct commit *commit; - int keep_empty = flags & TODO_LIST_KEEP_EMPTY; + int drop_empty = flags & TODO_LIST_DROP_EMPTY; + int ask_empty = flags & TODO_LIST_ASK_EMPTY; const char *insn = flags & TODO_LIST_ABBREVIATE_CMDS ? "p" : "pick"; int rebase_merges = flags & TODO_LIST_REBASE_MERGES; @@ -4958,11 +4999,13 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc, return make_script_with_merges(&pp, &revs, out, flags); while ((commit = get_revision(&revs))) { - int is_empty = is_original_commit_empty(commit); + int is_empty = is_original_commit_empty(commit); if (!is_empty && (commit->object.flags & PATCHSAME)) continue; - if (!keep_empty && is_empty) + if (is_empty && drop_empty) + continue; + if (is_empty && ask_empty) strbuf_addf(out, "%c ", comment_line_char); strbuf_addf(out, "%s %s ", insn, oid_to_hex(&commit->object.oid)); @@ -5100,7 +5143,8 @@ int todo_list_write_to_file(struct repository *r, struct todo_list *todo_list, todo_list_to_strbuf(r, todo_list, &buf, num, flags); if (flags & TODO_LIST_APPEND_TODO_HELP) - append_todo_help(flags & TODO_LIST_KEEP_EMPTY, count_commands(todo_list), + append_todo_help(!(flags & TODO_LIST_ASK_EMPTY), + count_commands(todo_list), shortrevisions, shortonto, &buf); res = write_message(buf.buf, buf.len, file, 0); diff --git a/sequencer.h b/sequencer.h index e9a0e03ea2..1c3abb661c 100644 --- a/sequencer.h +++ b/sequencer.h @@ -39,7 +39,9 @@ struct replay_opts { int allow_rerere_auto; int allow_empty; int allow_empty_message; + int drop_redundant_commits; int keep_redundant_commits; + int ask_on_initially_empty; int verbose; int quiet; int reschedule_failed_exec; @@ -134,7 +136,7 @@ int sequencer_rollback(struct repository *repo, struct replay_opts *opts); int sequencer_skip(struct repository *repo, struct replay_opts *opts); int sequencer_remove_state(struct replay_opts *opts); -#define TODO_LIST_KEEP_EMPTY (1U << 0) +/* #define TODO_LIST_KEEP_EMPTY (1U << 0) */ /* No longer used */ #define TODO_LIST_SHORTEN_IDS (1U << 1) #define TODO_LIST_ABBREVIATE_CMDS (1U << 2) #define TODO_LIST_REBASE_MERGES (1U << 3) @@ -150,6 +152,8 @@ int sequencer_remove_state(struct replay_opts *opts); * `--onto`, we do not want to re-generate the root commits. */ #define TODO_LIST_ROOT_WITH_ONTO (1U << 6) +#define TODO_LIST_DROP_EMPTY (1U << 7) +#define TODO_LIST_ASK_EMPTY (1U << 8) int sequencer_make_script(struct repository *r, struct strbuf *out, int argc, diff --git a/t/t3421-rebase-topology-linear.sh b/t/t3421-rebase-topology-linear.sh index 325072b0a3..d23e0bf778 100755 --- a/t/t3421-rebase-topology-linear.sh +++ b/t/t3421-rebase-topology-linear.sh @@ -230,7 +230,7 @@ test_run_rebase () { test_run_rebase success '' test_run_rebase success -m test_run_rebase success -i -test_have_prereq !REBASE_P || test_run_rebase failure -p +test_have_prereq !REBASE_P || test_run_rebase success -p test_run_rebase () { result=$1 @@ -245,7 +245,7 @@ test_run_rebase () { test_run_rebase success '' test_run_rebase success -m test_run_rebase success -i -test_have_prereq !REBASE_P || test_run_rebase failure -p +test_have_prereq !REBASE_P || test_run_rebase success -p test_run_rebase success --rebase-merges # m diff --git a/t/t3424-rebase-empty.sh b/t/t3424-rebase-empty.sh new file mode 100755 index 0000000000..9d52e1417f --- /dev/null +++ b/t/t3424-rebase-empty.sh @@ -0,0 +1,89 @@ +#!/bin/sh + +test_description='git rebase of commits that start or become empty' + +. ./test-lib.sh + +test_expect_success 'setup test repository' ' + test_write_lines 1 2 3 4 5 6 7 8 9 10 >numbers && + test_write_lines A B C D E F G H I J >letters && + git add numbers letters && + git commit -m A && + + git branch upstream && + git branch localmods && + + git checkout upstream && + test_write_lines A B C D E >letters && + git add letters && + git commit -m B && + + test_write_lines 1 2 3 4 five 6 7 8 9 ten >numbers && + git add numbers && + git commit -m C && + + git checkout localmods && + test_write_lines 1 2 3 4 five 6 7 8 9 10 >numbers && + git add numbers && + git commit -m C2 && + + git commit --allow-empty -m D && + + test_write_lines A B C D E >letters && + git add letters && + git commit -m "Five letters ought to be enough for anybody" +' + +test_expect_success 'rebase --merge --empty=drop' ' + git checkout -B testing localmods && + git rebase --merge --empty=drop upstream && + + test_write_lines C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --merge --empty=keep' ' + git checkout -B testing localmods && + git rebase --merge --empty=keep upstream && + + test_write_lines D C2 C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --merge --empty=ask' ' + git checkout -B testing localmods && + test_must_fail git rebase --merge --empty=ask upstream && + + test_must_fail git rebase --skip && + git commit --allow-empty && + git rebase --continue && + + test_write_lines D C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +GIT_SEQUENCE_EDITOR=: && export GIT_SEQUENCE_EDITOR + +test_expect_success 'rebase --interactive --empty=drop' ' + git checkout -B testing localmods && + git rebase --interactive --empty=drop upstream && + + test_write_lines C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --interactive --empty=keep' ' + git checkout -B testing localmods && + git rebase --interactive --empty=keep upstream && + + test_write_lines D C2 C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + + +test_done diff --git a/t/t3427-rebase-subtree.sh b/t/t3427-rebase-subtree.sh index bec48e6a1f..468ebc1bef 100755 --- a/t/t3427-rebase-subtree.sh +++ b/t/t3427-rebase-subtree.sh @@ -85,23 +85,27 @@ test_expect_failure REBASE_P 'Rebase -Xsubtree --keep-empty --preserve-merges -- verbose test "$(commit_message HEAD)" = "Empty commit" ' -test_expect_success 'Rebase -Xsubtree --keep-empty --onto commit' ' +test_expect_success 'Rebase -Xsubtree --empty=ask --onto commit' ' reset_rebase && git checkout -b rebase-onto to-rebase && - test_must_fail git rebase -Xsubtree=files_subtree --keep-empty --onto files-master master && + test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --onto files-master master && : first pick results in no changes && - git rebase --continue && + test_must_fail git rebase --skip && + : last pick was an empty commit that has no changes, but we want to keep it && + git commit --allow-empty && verbose test "$(commit_message HEAD~2)" = "master4" && verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" ' -test_expect_success 'Rebase -Xsubtree --keep-empty --rebase-merges --onto commit' ' +test_expect_success 'Rebase -Xsubtree --empty=ask --rebase-merges --onto commit' ' reset_rebase && git checkout -b rebase-merges-onto to-rebase && - test_must_fail git rebase -Xsubtree=files_subtree --keep-empty --rebase-merges --onto files-master --root && + test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --rebase-merges --onto files-master --root && : first pick results in no changes && - git rebase --continue && + test_must_fail git rebase --skip && + : last pick was an empty commit that has no changes, but we want to keep it && + git commit --allow-empty && verbose test "$(commit_message HEAD~2)" = "master4" && verbose test "$(commit_message HEAD~)" = "files_subtree/master5" && verbose test "$(commit_message HEAD)" = "Empty commit" From patchwork Mon Dec 23 18:49:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11308623 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B597921 for ; Mon, 23 Dec 2019 18:50:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F380206CB for ; Mon, 23 Dec 2019 18:50:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bIUIZjl9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726829AbfLWSuE (ORCPT ); Mon, 23 Dec 2019 13:50:04 -0500 Received: from mail-ed1-f42.google.com ([209.85.208.42]:32917 "EHLO mail-ed1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726787AbfLWSuE (ORCPT ); Mon, 23 Dec 2019 13:50:04 -0500 Received: by mail-ed1-f42.google.com with SMTP id r21so16130331edq.0 for ; Mon, 23 Dec 2019 10:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=3muzs1s8jPipA1T8GQk7Xh/VUjMuS5qZYkTINqYuvjk=; b=bIUIZjl9N9mUTNHE+pDW/g+LNisdpKRsWKS+TGoNtpIUR/DWiVDxd9GENSxpgFW1Gf VtTMdO1TYfax/JomWBXR625Xvw9jY3kFm9U+hSQ/4lYcKOxvBKllqaMjiVWbgrOBptAf o5BmSxUaMTVcbHYXJJP7pdzS3dZ61oY/iWy0WhkICH0kgB4WkkIoYIDmgGXmk8rT8Wg8 IqfNhKTNQPdSj5jrwjg0LNVTeEXZUSHe4kYe3X+fJfha+faJxQLcTZBNYP7om8ZZClVw UbU7VMPSrV1IjYYlTeg+duVhJt5p0zFL9YTITvtPIx61+yw/xiraekAPwbZqDnFzrdXa BePQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=3muzs1s8jPipA1T8GQk7Xh/VUjMuS5qZYkTINqYuvjk=; b=HUDItbvYsMfMlSBd9MP2/EH+NP8pfydOkht4tFEbC9MQVLk6n+H8dV5IedlLlYq02X K8gP1fEDIx2OYCby36p9Am6vLEMIJ82BTgTZdjshkoHua+QswulpouK4RIrIcDzyICoo 0G6tFdp6GVq7mQOoPB36piIrwJL9wd4wdiSE6VIM2wJ7FbZ/hfPzMI310F+4SVO3irnz ludEAVQ7FG48hszQfIJGCHZIs6EQE4USA2ceKyZkSWBtEXLzUJgLOYVViqK9t00KzGV/ s9hh8zmeph2g1mDDFia6VyBS36UGt3RjXBr6VjhvqQAbidTytFLljAv1vC61AZ9//ccO +A0Q== X-Gm-Message-State: APjAAAWjJ9apna74EMhgsMFbY6KD6/dh025STNvxi2vbZx1tL6fMe5cR s9uiwOzpglMjZ1nhGF0iSYLe8Eue X-Google-Smtp-Source: APXvYqxmUh4a1h/IhEvoyf4zZxIez/p4hVZPCPeKw/KAqOvv4A57QdPpI0IGVdI48MBinBQ5SBy8gQ== X-Received: by 2002:a50:fb96:: with SMTP id e22mr34411843edq.18.1577127002734; Mon, 23 Dec 2019 10:50:02 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y4sm2375773ejp.50.2019.12.23.10.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2019 10:50:02 -0800 (PST) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 23 Dec 2019 18:49:46 +0000 Subject: [PATCH v2 02/15] t3406: simplify an already simple test Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, phillip.wood@dunelm.org.uk, liu.denton@gmail.com, gitster@pobox.com, plroskin@gmail.com, alban.gruin@gmail.com, szeder.dev@gmail.com, Junio C Hamano , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren When the merge backend was re-implemented on top of the interactive backend, the output of rebase --merge changed a little. This change allowed this test to be simplified, though it wasn't noticed until now. Simplify the testcase a little. Signed-off-by: Elijah Newren --- t/t3406-rebase-message.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index b393e1e9fe..0c2c569f95 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -18,11 +18,8 @@ test_expect_success 'setup' ' ' test_expect_success 'rebase -m' ' - git rebase -m master >report && - >expect && - sed -n -e "/^Already applied: /p" \ - -e "/^Committed: /p" report >actual && - test_cmp expect actual + git rebase -m master >actual && + test_must_be_empty actual ' test_expect_success 'rebase against master twice' ' From patchwork Mon Dec 23 18:49:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11308629 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A499D921 for ; Mon, 23 Dec 2019 18:50:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 818C52073A for ; Mon, 23 Dec 2019 18:50:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LHI6F5wq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726853AbfLWSuF (ORCPT ); Mon, 23 Dec 2019 13:50:05 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:45715 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbfLWSuF (ORCPT ); Mon, 23 Dec 2019 13:50:05 -0500 Received: by mail-ed1-f66.google.com with SMTP id v28so16083312edw.12 for ; Mon, 23 Dec 2019 10:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=FGi8Re5Xsr69EALhyOtGMpdb7t1ii+72BJ5qReN/2e0=; b=LHI6F5wqgsyQjaZZdRpAg+2hHQ1BdZky91zW5TKqzEaSwf2VERSM8yT5zOHFNl0ZE+ 7p76jGPjDJ+rVzv4o1GkzJXTVG+dXS4Vndj65b49J4IXaaBIX5lrrjU6jGqPLY1NRBlF PcSw4WhKfDqYR4fzgtljspx6FpqVl54dV8jEz+Tu5GpweVaX/eziJhwVDQioBw4VGLVT +N26930MvfS2lb1/ZB4GGfR+c+6GWb/NsI9oHwOa+nPQTAo88Jj/6f2wftVf5ldoC5jU KEHg2jMhjsO3i/3YOXxyEtH3236wMYdNVChO50S8538VoUljT83XrUg7QfHVZAhd8avD WplQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=FGi8Re5Xsr69EALhyOtGMpdb7t1ii+72BJ5qReN/2e0=; b=ZLyqVS+oTfLMs4IxMOkS6j0mBFhF4f++oQw9eS4tHJHayKwfJl1gTNE52ZO8tGcIyi YlQKipWa7SzLjL9oweHXXGqp9+URruRzG019EOZEA2ffXhaFemeKAYmt5rgs+tkESskr eOlE8MdVSOjtkqH3WRrimagaUS6DbN+4UK1kpIdrcNlhaZYMCAZycuCFeZyLpUp+Tjae ZRRyaMql/y1PGazCvQLPOt7tlKSUor5246luoEY2ByHxZukqAmifk6swcFezP5ObPhel DbBSH91W4c+IuDYBRMeY5kvp1hxaExqOXBAQz1J8uG2K7ARxT/FDl9vYwHvWDY22SjGK Ib1g== X-Gm-Message-State: APjAAAUf7KoGx4KzA6cRqhICXkfke8jyzLMZkVbNV/WAG4QEDAgtMVbF 1m3AeUqkrd79k/NLZcuaiskiCMIQ X-Google-Smtp-Source: APXvYqwr2vzmnGDiUXKdrMSzk0W1Xj4IdBKInLX/4OiiKcARLkbW3rKFTlC8bxWucwiHm4U1I6ByuA== X-Received: by 2002:a50:a2c7:: with SMTP id 65mr34127168edm.144.1577127003475; Mon, 23 Dec 2019 10:50:03 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q3sm2392071eju.88.2019.12.23.10.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2019 10:50:03 -0800 (PST) Message-Id: <49388b79fddc339f3a5df747406621ec5ad28789.1577127000.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 23 Dec 2019 18:49:47 +0000 Subject: [PATCH v2 03/15] rebase, sequencer: remove the broken GIT_QUIET handling Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, phillip.wood@dunelm.org.uk, liu.denton@gmail.com, gitster@pobox.com, plroskin@gmail.com, alban.gruin@gmail.com, szeder.dev@gmail.com, Junio C Hamano , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren The GIT_QUIET environment variable was used to signal the non-am backends that the rebase should perform quietly. The preserve-merges backend does not make use of the quiet flag anywhere (other than to write out its state whenever it writes state), and this mechanism was broken in the conversion from shell to C. Since this environment variable was specifically designed for scripts and the only backend that would still use it is no longer a script, just gut this code. A subsequent commit will fix --quiet for the interactive/merge backend in a different way. Signed-off-by: Elijah Newren --- builtin/rebase.c | 6 ++---- sequencer.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 6903249307..32026a62e8 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -718,8 +718,8 @@ static int rebase_write_basic_state(struct rebase_options *opts) opts->onto ? oid_to_hex(&opts->onto->object.oid) : ""); write_file(state_dir_path("orig-head", opts), "%s", oid_to_hex(&opts->orig_head)); - write_file(state_dir_path("quiet", opts), "%s", - opts->flags & REBASE_NO_QUIET ? "" : "t"); + if (!(opts->flags & REBASE_NO_QUIET)) + write_file(state_dir_path("quiet", opts), "%s", ""); if (opts->flags & REBASE_VERBOSE) write_file(state_dir_path("verbose", opts), "%s", ""); if (opts->strategy) @@ -1178,8 +1178,6 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action) add_var(&script_snippet, "revisions", opts->revisions); add_var(&script_snippet, "restrict_revision", opts->restrict_revision ? oid_to_hex(&opts->restrict_revision->object.oid) : NULL); - add_var(&script_snippet, "GIT_QUIET", - opts->flags & REBASE_NO_QUIET ? "" : "t"); sq_quote_argv_pretty(&buf, opts->git_am_opts.argv); add_var(&script_snippet, "git_am_opt", buf.buf); strbuf_release(&buf); diff --git a/sequencer.c b/sequencer.c index d2c11f34b7..71062212a5 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2688,8 +2688,6 @@ static void write_strategy_opts(struct replay_opts *opts) int write_basic_state(struct replay_opts *opts, const char *head_name, struct commit *onto, const char *orig_head) { - const char *quiet = getenv("GIT_QUIET"); - if (head_name) write_file(rebase_path_head_name(), "%s\n", head_name); if (onto) @@ -2698,8 +2696,8 @@ int write_basic_state(struct replay_opts *opts, const char *head_name, if (orig_head) write_file(rebase_path_orig_head(), "%s\n", orig_head); - if (quiet) - write_file(rebase_path_quiet(), "%s\n", quiet); + if (opts->quiet) + write_file(rebase_path_quiet(), "%s", ""); if (opts->verbose) write_file(rebase_path_verbose(), "%s", ""); if (opts->strategy) From patchwork Mon Dec 23 18:49:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11308627 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9950213A4 for ; Mon, 23 Dec 2019 18:50:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7544920643 for ; Mon, 23 Dec 2019 18:50:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PxZsFGsf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726882AbfLWSuH (ORCPT ); Mon, 23 Dec 2019 13:50:07 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:41895 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726787AbfLWSuG (ORCPT ); Mon, 23 Dec 2019 13:50:06 -0500 Received: by mail-ed1-f65.google.com with SMTP id c26so16113468eds.8 for ; Mon, 23 Dec 2019 10:50:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=qn1fi0por3x0HTg6UJQb4898IQuTlhoQdD5bPS1bny4=; b=PxZsFGsfVAN98oR6DkyEORKZysp5xd7w4YyNjthDDpseD/ZMNqQt6oCx7B4/bBYWJW yUSuBcZXSrDzbL+Luq0wngzTXSJ3tP4HhllOELnU+VCIKjRfC8ORhHvAkNpgdekPu09V EU40CWN4qA71vPr4SmjIMNbAT5xk39jdkv59NbD4DRX4vDBJtMd0uQY0/wyMqbPPVMaa 2kh6sZHFdzLfNb8n/4amQGtJ8JOcR/puvIUTO5KqsrLYVR8g32+Vb+XiFnqVvYxsbn4M iU2QeGOc8PqryE38E+LlsvCGkBtpNOg1fZH1fySEbodJTpInT6GxRR+3OHpwOzya3JQX c7kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=qn1fi0por3x0HTg6UJQb4898IQuTlhoQdD5bPS1bny4=; b=QvoeDLb3vaD0w7EgLBiDmXsmmXFGBo/r5tCrJYBBQ0cZTSf1j+D69r5Vuvc9zumjhb dCRiaYJdy5g/pi8cx0mGzdJSyh+FZaW0JIC7/aGPQfgAzwoUo2IVjJNHrI+bjRHx2e2m HBz4mbq6NVbLWt7I9qmfMcnOaFL+FKB30b/cKBBCjDSJXWKv5GBoJqcUntlztSAIufI2 ISGUossiHfiNlpYIc1CC82Y85JPHKiO9Jp5vjFg6E0Re+gcRgyf+8HVDRyqcmkTAO2gY OX5b5ulbfPjmo4f+euOKD0FWg52LM1Bgb3zn1SUV/flmN3umo9sZQ4TX2kHHtNJzdLGC zz5A== X-Gm-Message-State: APjAAAXOSJzZEklKOt4haRzx2Qqiz0wg9YHv3JP6EcIA4mUpulbRXeZ6 4/VqGakGQTFtX66aiP5VCpFMW3Ud X-Google-Smtp-Source: APXvYqybEbnT+1au4Bbmlu420OMb3DnHhuuIv0joPG/zQJ6WEoqfn0iQJ72u07kwnsnqg0p8r/F4zg== X-Received: by 2002:a50:9ee8:: with SMTP id a95mr34282351edf.86.1577127004166; Mon, 23 Dec 2019 10:50:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i4sm2327153edr.59.2019.12.23.10.50.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2019 10:50:03 -0800 (PST) Message-Id: <478479358ff21afe6b8374f076d2ed5e139ae6c0.1577127000.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 23 Dec 2019 18:49:48 +0000 Subject: [PATCH v2 04/15] rebase: make sure to pass along the quiet flag to the sequencer Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, phillip.wood@dunelm.org.uk, liu.denton@gmail.com, gitster@pobox.com, plroskin@gmail.com, alban.gruin@gmail.com, szeder.dev@gmail.com, Junio C Hamano , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren Signed-off-by: Elijah Newren --- builtin/rebase.c | 3 ++- t/t3400-rebase.sh | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 32026a62e8..5014c9a437 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -126,6 +126,7 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts) replay.keep_redundant_commits = (opts->empty == EMPTY_KEEP); replay.ask_on_initially_empty = (opts->empty == EMPTY_ASK && !(opts->flags & REBASE_INTERACTIVE_EXPLICIT)); + replay.quiet = !(opts->flags & REBASE_NO_QUIET); replay.verbose = opts->flags & REBASE_VERBOSE; replay.reschedule_failed_exec = opts->reschedule_failed_exec; replay.committer_date_is_author_date = @@ -1502,7 +1503,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) N_("allow pre-rebase hook to run")), OPT_NEGBIT('q', "quiet", &options.flags, N_("be quiet. implies --no-stat"), - REBASE_NO_QUIET| REBASE_VERBOSE | REBASE_DIFFSTAT), + REBASE_NO_QUIET | REBASE_VERBOSE | REBASE_DIFFSTAT), OPT_BIT('v', "verbose", &options.flags, N_("display a diffstat of what changed upstream"), REBASE_NO_QUIET | REBASE_VERBOSE | REBASE_DIFFSTAT), diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 221b35f2df..79762b989a 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -206,12 +206,18 @@ test_expect_success 'cherry-picked commits and fork-point work together' ' test_cmp expect D ' -test_expect_success 'rebase -q is quiet' ' +test_expect_success 'rebase --am -q is quiet' ' git checkout -b quiet topic && git rebase -q master >output.out 2>&1 && test_must_be_empty output.out ' +test_expect_success 'rebase --merge -q is quiet' ' + git checkout -B quiet topic && + git rebase --merge -q master >output.out 2>&1 && + test_must_be_empty output.out +' + test_expect_success 'Rebase a commit that sprinkles CRs in' ' ( echo "One" && From patchwork Mon Dec 23 18:49:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11308635 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 231DC921 for ; Mon, 23 Dec 2019 18:50:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02425206CB for ; Mon, 23 Dec 2019 18:50:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MaSptI32" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726920AbfLWSuL (ORCPT ); Mon, 23 Dec 2019 13:50:11 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:38105 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfLWSuH (ORCPT ); Mon, 23 Dec 2019 13:50:07 -0500 Received: by mail-ed1-f65.google.com with SMTP id i16so16119021edr.5 for ; Mon, 23 Dec 2019 10:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=mI8fjeSdKsXqLIxIijlISP0IXKZR1ghClmld4gvxCyc=; b=MaSptI32BRN+ieHqEQw2+Cg9nfYy5i8A+a94+LNs64Nw/H6gDuoTO8c8q5D87VimDD e+sQly/Y6H1bctYXjU9Mm5pJlT1b8Eem4Gi8+mt551LtIZTYNodb0M2PrCki9JojbpZy I5GN+d3y4QnFXeps2Qwwd5vaP6CSayAeGnbqwaEq+f5dCZTzPOM1V92AyFALJgO4Zped zQbM5bxK38uHhWX5gSpVpaNvxrrF88SP3xJIvytMIyI8W9zQeaVTvR1Egojp6tl4nXha QHDz/fFbCzFO1zodYFXLNMd3n1KvQYXkSDORqAF/iR3A+fQ7CXLBpiyjArJS3XFlojyu ZOww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=mI8fjeSdKsXqLIxIijlISP0IXKZR1ghClmld4gvxCyc=; b=mbbM+a5O/s/Qu4jo4nSAjbiz1e+JWHHmRAfUPQp73iAA67POYP8/hZIvrbpCHY2cr8 97+oAcWiU3DZ+F4m45xXwzDIRWFoeHXlqBhaOsHVg+kbViGdf2utksxWW5l7aMKknVX+ POttbtUwmylasrjOJMIdgBLQRAX5F2cx0YO1sMfGkfBzwIE2FkH28Z9wqTZhvoc+dq3Z StxMB3SRYsLJ79oc2k4i9PrPT79b/7yX0ZQizWJpOhaO/cfVWJYYJZOyNjVN5KTsecAH 3EQxMk/PygeDCaPXKFVEIxiU9A6l0TFYqM2IuPMjzVMVg9p3pVj+DynEKXE+XROPQrtH dJXg== X-Gm-Message-State: APjAAAVhz2tcB0KiMNdG6K39sVUBGW1VPml7J7F1udwt86ltjkF76rT5 ua2ckPNTkJJ5Q99eVPrXceyq536X X-Google-Smtp-Source: APXvYqxruSLG8HxO5Ce+rujlXFHe+DSyEjBpOYOLFYjgN6ojWAOtmWoWsxlRBozMQXBNJKEIQ7tyBg== X-Received: by 2002:a05:6402:22cf:: with SMTP id dm15mr34867667edb.233.1577127004885; Mon, 23 Dec 2019 10:50:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ba29sm2329186edb.47.2019.12.23.10.50.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2019 10:50:04 -0800 (PST) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 23 Dec 2019 18:49:49 +0000 Subject: [PATCH v2 05/15] rebase: fix handling of restrict_revision Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, phillip.wood@dunelm.org.uk, liu.denton@gmail.com, gitster@pobox.com, plroskin@gmail.com, alban.gruin@gmail.com, szeder.dev@gmail.com, Junio C Hamano , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren restrict_revision in the original shell script was an excluded revision range. It is also treated that way by the am-backend. In the conversion from shell to C (see commit 6ab54d17be3f ("rebase -i: implement the logic to initialize $revisions in C", 2018-08-28)), the interactive-backend accidentally treated it as a positive revision rather than a negated one. This was missed as there were no tests in the testsuite that tested an interactive rebase with fork-point behavior. Signed-off-by: Elijah Newren --- builtin/rebase.c | 4 ++-- t/t3400-rebase.sh | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 5014c9a437..f1de5c8186 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -364,8 +364,8 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags) argv_array_pushl(&make_script_args, "", revisions, NULL); if (opts->restrict_revision) - argv_array_push(&make_script_args, - oid_to_hex(&opts->restrict_revision->object.oid)); + argv_array_pushf(&make_script_args, "^%s", + oid_to_hex(&opts->restrict_revision->object.oid)); ret = sequencer_make_script(the_repository, &todo_list.buf, make_script_args.argc, make_script_args.argv, diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 79762b989a..71fd6396cd 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -165,11 +165,29 @@ test_expect_success 'rebase works with format.useAutoBase' ' git rebase master ' -test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' ' +test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg (--merge)' ' git checkout -b default-base master && git checkout -b default topic && git config branch.default.remote . && git config branch.default.merge refs/heads/default-base && + git rebase --merge && + git rev-parse --verify default-base >expect && + git rev-parse default~1 >actual && + test_cmp expect actual && + git checkout default-base && + git reset --hard HEAD^ && + git checkout default && + git rebase --merge && + git rev-parse --verify default-base >expect && + git rev-parse default~1 >actual && + test_cmp expect actual +' + +test_expect_success 'default to common base in @{upstream}s reflog if no upstream arg' ' + git checkout -B default-base master && + git checkout -B default topic && + git config branch.default.remote . && + git config branch.default.merge refs/heads/default-base && git rebase && git rev-parse --verify default-base >expect && git rev-parse default~1 >actual && From patchwork Mon Dec 23 18:49:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11308639 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67C8513A4 for ; Mon, 23 Dec 2019 18:50:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EA0E2073A for ; Mon, 23 Dec 2019 18:50:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kKFveGNx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbfLWSuM (ORCPT ); Mon, 23 Dec 2019 13:50:12 -0500 Received: from mail-ed1-f51.google.com ([209.85.208.51]:34027 "EHLO mail-ed1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbfLWSuH (ORCPT ); Mon, 23 Dec 2019 13:50:07 -0500 Received: by mail-ed1-f51.google.com with SMTP id l8so16132791edw.1 for ; Mon, 23 Dec 2019 10:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=QDbhLq+anCcBMZ0842z90xgm8GuAOJH2crkKX3N2XTU=; b=kKFveGNxd1RHG9BFDhnBc8L4Ap5A0umwHmsRenkk+Z7tAj/vYsGx12ockb2g73As+c dN1Aneqfp/fcsSlESObCqD5ilozJHU5PMujxmsTP5xUaDbLZBB4gwK/H/YkukkM+2H1w JxIg6JR8rZvFXTCXWHRBY5VSqJ/q3UFD9GSl39OOWSdQr8CYFcVcRHtOszoSLWVqizK6 6r1amOFDd+zCBPRBcOsWqVuLu2BVBso4dgJmFYsJ2iU7is0awaghmfLlX537kHzX5MGr 91q9kNtD1F7Rx3bsD7wqc/7W1z7Bes3CQ7M3B9ASVRw+aODOJKNX/sTK6ETXmvF+lBVy uGdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=QDbhLq+anCcBMZ0842z90xgm8GuAOJH2crkKX3N2XTU=; b=GeIkkjAcV982SuB/XQWR65NP7rXcPuFNeJiog18Q0YzDY1jxriwRJtCCzod3uk1JAe +nJ6sbC0p4Kj7Rmc8N6+fGQi1WkbDVOHDACXaUxnsiaShuX24sVt5nO1/gQqTX6f+k+0 aq42Q0tCxjD3F326WGDorp6Cqs1BLQ+TODzbo9DgPKh/GHxqtRzdWSMdm5wz6+I/WChJ 0PngjN4psQV4Gn5a1XZX4b90cZihhueeLbc8dxfrQDBvLHVh8A7DRb3M+u45lpIgixWx 9b1XJmN3J07e44J2Vcx4LdenvgoSBACEmk1wUGMvEs3LtweMoQYZzqxt2jzyPStp3YqB r49g== X-Gm-Message-State: APjAAAXJsseM2C7OEd48xSz6jZ+lDq9OVjBtuiq7TIAp3nu+x3/xaIRj KEYaUuofEXwHXXoD24iatIscpnfG X-Google-Smtp-Source: APXvYqyMv1im42C+aEoxWCNu274rqJiwNDwKmE+iQ37WEH4426WHTgdR48ZTRmXfXRPM+PXhbQhu6Q== X-Received: by 2002:a17:906:27d5:: with SMTP id k21mr33323086ejc.328.1577127005554; Mon, 23 Dec 2019 10:50:05 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u20sm2320882edd.62.2019.12.23.10.50.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2019 10:50:05 -0800 (PST) Message-Id: <34a69def330c2d0fc00f34b0897604c55bed1514.1577127000.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 23 Dec 2019 18:49:50 +0000 Subject: [PATCH v2 06/15] t3432: make these tests work with either am or merge backends Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, phillip.wood@dunelm.org.uk, liu.denton@gmail.com, gitster@pobox.com, plroskin@gmail.com, alban.gruin@gmail.com, szeder.dev@gmail.com, Junio C Hamano , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren t3432 had several stress tests for can_fast_forward(), whose intent was to ensure we were using the optimization of just fast forwarding when possible. However, these tests verified that fast forwards had happened based on the output that rebase printed to the terminal. We can instead test more directly that we actually fast-forwarded by checking the reflog, which also has the side effect of making the tests applicable for the merge/interactive backend. This change does lose the distinction between "noop" and "noop-force", but as stated in commit c9efc216830f ("t3432: test for --no-ff's interaction with fast-forward", 2019-08-27) which introduced that distinction: "These tests aren't supposed to endorse the status quo, just test for what we're currently doing.". This change does not actually run these tests with the merge/interactive backend; instead this is just a preparatory commit. A subsequent commit which fixes can_fast_forward() to work with that backend will then also change t3432 to add tests of that backend as well. Signed-off-by: Elijah Newren --- t/t3432-rebase-fast-forward.sh | 48 ++++++++++++++++------------------ 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh index 92f95b57da..7432c0e241 100755 --- a/t/t3432-rebase-fast-forward.sh +++ b/t/t3432-rebase-fast-forward.sh @@ -44,19 +44,15 @@ test_rebase_same_head_ () { test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" " oldhead=\$(git rev-parse HEAD) && test_when_finished 'git reset --hard \$oldhead' && + cp .git/logs/HEAD expect && git rebase$flag $* >stdout && if test $what = work then - # Must check this case first, for 'is up to - # date, rebase forced[...]rewinding head' cases - test_i18ngrep 'rewinding head' stdout + old=\$(wc -l X-Patchwork-Id: 11308637 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8FAD017EE for ; Mon, 23 Dec 2019 18:50:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A87B2073A for ; Mon, 23 Dec 2019 18:50:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N7CzNyyU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726928AbfLWSuM (ORCPT ); Mon, 23 Dec 2019 13:50:12 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:41902 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726884AbfLWSuI (ORCPT ); Mon, 23 Dec 2019 13:50:08 -0500 Received: by mail-ed1-f68.google.com with SMTP id c26so16113541eds.8 for ; Mon, 23 Dec 2019 10:50:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ckHsml5tF8rbwrITNsBewcKB/RzAcohGKcZWm6pvdhc=; b=N7CzNyyUBFjIKp6TcFAmumdMqvHwek8zfsvVo3bRsaILY5Otxlvqp2iBzt5mJMAGw9 wJqO1AyEe5f0HXJrlQWkbAAL0/tN3qWksa76uwBXwY1VllgZwpHe095aasLdKQ00/b4a aJgUn2eBOKEFlcYHB0q/0cCOJu3QzHJpulyc8yZ0dy1mBbKzt+VNaM8b94zjSyrVnxJL s2IdnBZmD7p8DmInVngvumN7Jsbcu9ZzTvYhgRdW0ww+kEWQwjCvgWqcJ9TomRhu5hAH YlrECxWbMGwy4HARr+Q+k4PiI01bDx2dZrIQpfaqLGIInk0KskwiXVuhszNXuX9C98UY Vc5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ckHsml5tF8rbwrITNsBewcKB/RzAcohGKcZWm6pvdhc=; b=p0tiijd6u4sAVN/Y0GfG3eGUimV056quHVKL95F+42Z3KcaNBmEwtkoXQEfBfYoPNw ZYMQj4L6UEt2dXRowP/Z/HtkKmNzBVyYVvlY4PFWqPjzZP1o5ynmGdAO/cUNTG5YSEwG sxCexBzhc5qT9t2LKotamQvDL+CiburEO0zhKTJlnvfrzso3/ZuZcnJmOc+C53xEENkS fJw9uDJnL7tFb9LHSENe+jxhxELjD3/ddQq+0pOLb28e910L8Lk9GIBaRYJxV/Q7wMle qCgzdzoKSyhvEAw/4DfmnJQQWcB65VS2k+J4D4B+EcXmUICw7ujvDwS8hQ7fJEKduP7O DouA== X-Gm-Message-State: APjAAAXuHMCvnz36e4+YOU2sNiWPbqhJGQxkomV6wyAdYsWH5tZbRgUv EBb/pGB5dRqpmOGhib/5jtOD+zKW X-Google-Smtp-Source: APXvYqycfd42q5FdHg2JUFxc53qPuixWf+UblMbyOBcf5wwwaDCiwUIBD779MV/uJHTjRif8rRdOMA== X-Received: by 2002:a17:906:2651:: with SMTP id i17mr33419919ejc.246.1577127006282; Mon, 23 Dec 2019 10:50:06 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u13sm2384708ejz.69.2019.12.23.10.50.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2019 10:50:05 -0800 (PST) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 23 Dec 2019 18:49:51 +0000 Subject: [PATCH v2 07/15] rebase: allow more types of rebases to fast-forward Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, phillip.wood@dunelm.org.uk, liu.denton@gmail.com, gitster@pobox.com, plroskin@gmail.com, alban.gruin@gmail.com, szeder.dev@gmail.com, Junio C Hamano , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren In the past, we dis-allowed rebases using the interactive backend from performing a fast-forward to short-circuit the rebase operation. This made sense for explicitly interactive rebases and some implicitly interactive rebases, but certainly became overly stringent when the merge backend was re-implemented via the interactive backend. Just as the am-based rebase has always had to disable the fast-forward based on a variety of conditions or flags (e.g. --signoff, --whitespace, etc.), we need to do the same but now with a few more options. However, continuing to use REBASE_FORCE for tracking this is problematic because the interactive backend used it for a different purpose. (When REBASE_FORCE wasn't set, the interactive backend would not fast-forward the whole series but would fast-forward individual "pick" commits at the beginning of the todo list, and then a squash or something would cause it to start generating new commits.) So, introduce a new allow_preemptive_ff flag contained within cmd_rebase() and use it to track whether we are going to allow a pre-emptive fast-forward that short-circuits the whole rebase. Signed-off-by: Elijah Newren --- builtin/rebase.c | 18 ++++++++++++++---- t/t3432-rebase-fast-forward.sh | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index f1de5c8186..7027e34567 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1493,6 +1493,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) struct object_id squash_onto; char *squash_onto_name = NULL; int reschedule_failed_exec = -1; + int allow_preemptive_ff = 1; struct option builtin_rebase_options[] = { OPT_STRING(0, "onto", &options.onto_name, N_("revision"), @@ -1804,11 +1805,18 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) options.ignore_date) options.flags |= REBASE_FORCE; + if ((options.flags & REBASE_INTERACTIVE_EXPLICIT) || + (action != ACTION_NONE) || + (exec.nr > 0) || + options.autosquash) { + allow_preemptive_ff = 0; + } + for (i = 0; i < options.git_am_opts.argc; i++) { const char *option = options.git_am_opts.argv[i], *p; if (!strcmp(option, "--whitespace=fix") || !strcmp(option, "--whitespace=strip")) - options.flags |= REBASE_FORCE; + allow_preemptive_ff = 0; else if (skip_prefix(option, "-C", &p)) { while (*p) if (!isdigit(*(p++))) @@ -2144,12 +2152,14 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) /* * Check if we are already based on onto with linear history, * in which case we could fast-forward without replacing the commits - * with new commits recreated by replaying their changes. This - * optimization must not be done if this is an interactive rebase. + * with new commits recreated by replaying their changes. + * + * Note that can_fast_forward() initializes merge_base, so we have to + * call it before checking allow_preemptive_ff. */ if (can_fast_forward(options.onto, options.upstream, options.restrict_revision, &options.orig_head, &merge_base) && - !is_interactive(&options)) { + allow_preemptive_ff) { int flag; if (!(options.flags & REBASE_FORCE)) { diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh index 7432c0e241..40388ccf9f 100755 --- a/t/t3432-rebase-fast-forward.sh +++ b/t/t3432-rebase-fast-forward.sh @@ -30,6 +30,8 @@ test_rebase_same_head () { shift && test_rebase_same_head_ $status_n $what_n $cmp_n "" "$*" && test_rebase_same_head_ $status_f $what_f $cmp_f " --no-ff" "$*" + test_rebase_same_head_ $status_n $what_n $cmp_n " --merge" "$*" && + test_rebase_same_head_ $status_f $what_f $cmp_f " --merge --no-ff" "$*" } test_rebase_same_head_ () { From patchwork Mon Dec 23 18:49:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11308631 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A774921 for ; Mon, 23 Dec 2019 18:50:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D291520643 for ; Mon, 23 Dec 2019 18:50:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YMe18cza" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726899AbfLWSuK (ORCPT ); Mon, 23 Dec 2019 13:50:10 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:33967 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726787AbfLWSuK (ORCPT ); Mon, 23 Dec 2019 13:50:10 -0500 Received: by mail-ed1-f65.google.com with SMTP id l8so16132844edw.1 for ; Mon, 23 Dec 2019 10:50:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=lhCCZYi0B8Y5DKm/BdvSQpxajRpqO1GMbHDyvaMtn7g=; b=YMe18cza7mPddi0OZs6CyEi5qo9FPfU99XNCPxBZX5Lud+HFT9Xb5shVB3OEBhE1Sp r2V33j7cz35uB/nOmqCG8I5FQN0Jyn1wj+r7rXrSJmsNkNlJ7mKGeqpudhIHac4zXZwk p9lxYAPMYlZGsG4MnzshEYNUyUWfwZ5tD4DiRdtE8QxnDbPaxt+Vg1RHnk2f0EqQQUMl KrcCqRVhyNIBEPATQZbiNngMuZrYG0IgbCyzhl80eaCNTJOtX57YFESiAonmj8GNmrYj F44vUymLI3qxz1rCT0c+VZFDECYHV4x5kuQa3eV3MfMUfsyEJ9cgb90jGRIErJOhmdIX lpSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=lhCCZYi0B8Y5DKm/BdvSQpxajRpqO1GMbHDyvaMtn7g=; b=Sj9X97tjZd2wN+yYxgttsCzw96AjonB5BAo98NivQJ5kyAyJiUdgRWLv/4OQB2bnZQ pSrpfrevKvYSvO+02URJ1csN8aWWIFCLj1ZXMOFwNMpjcC88ffhHFgNizDXyhy4gWx93 lcVeqXVrYuy2lo7Au5NcILIkfHP3I5OTkOKC8GpZjl3p0KsWdjDZSDrMsPp/IgcFqg9q JVaSUlF76SKFpuEL2Fy3xeGJjY+qOy1k5rnfVBBd1NTW71oyiawYfND6vKUv7mDz/6HR 9drubzRK0BVUjl3IuwdAe43e8AK+w9mFqDhKfYHmIO2OGuJYGlzzVGJQwi/zRlpuMkzU kEeA== X-Gm-Message-State: APjAAAWtgUvv5yby3mTWcv68dRWK53x6wsN+gG4NmX+X2xK4BgJVXPXL n6ZvoiXcyAPD4QKUZ+TNsNdt/b18 X-Google-Smtp-Source: APXvYqwrnvI9sqEwFD7BIj9Vxb/bNtVgbcfW/IcejGoBdZJWjvPAo9tAdUKAy/ghU+oYJUbo1DEvLw== X-Received: by 2002:aa7:d99a:: with SMTP id u26mr34342548eds.183.1577127007114; Mon, 23 Dec 2019 10:50:07 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ay8sm2420564ejb.6.2019.12.23.10.50.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Dec 2019 10:50:06 -0800 (PST) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Mon, 23 Dec 2019 18:49:52 +0000 Subject: [PATCH v2 08/15] git-rebase.txt: add more details about behavioral differences of backends Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, phillip.wood@dunelm.org.uk, liu.denton@gmail.com, gitster@pobox.com, plroskin@gmail.com, alban.gruin@gmail.com, szeder.dev@gmail.com, Junio C Hamano , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren Signed-off-by: Elijah Newren --- Documentation/git-rebase.txt | 102 +++++++++++++++++++++--- t/t3433-rebase-options-compatibility.sh | 5 +- 2 files changed, 94 insertions(+), 13 deletions(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index ff32ca1080..f1ace07c38 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -409,13 +409,10 @@ your branch contains commits which were dropped, this option can be used with `--keep-base` in order to drop those commits from your branch. --ignore-whitespace:: - Behaves differently depending on which backend is selected. -+ -'am' backend: When applying a patch, ignore changes in whitespace in -context lines if necessary. -+ -'interactive' backend: Treat lines with only whitespace changes as -unchanged for the sake of a three-way merge. + Ignore whitespace-only changes in the commits being rebased, + which may avoid "unnecessary" conflicts. (Both backends + currently have differing edgecase bugs with this option; see + BEHAVIORAL DIFFERENCES.) --whitespace=