From patchwork Fri Apr 10 17:51:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 11483515 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 E4CDC14B4 for ; Fri, 10 Apr 2020 17:51:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C52852082D for ; Fri, 10 Apr 2020 17:51:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ifXpwex/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726657AbgDJRvi (ORCPT ); Fri, 10 Apr 2020 13:51:38 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:46311 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726595AbgDJRvi (ORCPT ); Fri, 10 Apr 2020 13:51:38 -0400 Received: by mail-ed1-f68.google.com with SMTP id w4so1599054edv.13 for ; Fri, 10 Apr 2020 10:51:37 -0700 (PDT) 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=P9viWhQnWu0BgQ5CRfbADlrAq5dIrIvowrryXcXLOEI=; b=ifXpwex/Me8iYHKlFBREsDcv9v7pTMrjA9lTw/eGNN8rKxADqw84bfo1C/0gyuIIWa KLVHpRT6yQ9zWwaBB5KYuGTk8JqmuLD7dKrAgQQpGQBvFv5m2gd8i8w7squG5s/MjjK9 80+zDoHtDICoWNIr0I3DGzhOMU/y/r11hcdrYSZCBBcshP0/OJEH5S8t6JvBeYsh6Xl/ fuhUcMEtd/qL++UxrtU5qaWC7p6qdS6bzgO+E5iZcpPjvAWtpRmgOPfmkMdUQuLUYcZ6 GIku6cuq0wealyZVfNUM5Ik5AB4duDDe9lUsQXgS/KyFE87Hn4AabXT9GdGYsZhGq6hX 8Jog== 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=P9viWhQnWu0BgQ5CRfbADlrAq5dIrIvowrryXcXLOEI=; b=NE7Df3IJtKd6bFksBcWYiF6rQwZ9FrC/v94hKVjUI3AKhFVykLRQVFH4BA3jHnMpsA mChvEHnnVT/0WDuTcI0eCzzCPF5L8+NPsep3rIKNBfKMMyMCPfXa3wp+h28FOgeAB8h/ 8uyX+lK4+9W4GhFjL2y12j+DmVHIHZtj7GxZFu4Zto5+R+t5nTtoPGn9DWCC2175SgBX djKJPkuhNqDYpnzt2pAQD7cW8/0hBv+kGaLwWIojTf+J8GyK8GpeMzc6prfzyolqLESA wKPrtMoQ/WLGm0Y/tvwT0Z3REfkNy/V7EJjMMav8XSeax+LktZFwPsxxR4/xQ7XdPwpc bABQ== X-Gm-Message-State: AGi0PuYukD+Ff3IPIlSFtsDEig/lISTyx0oVhXvA6c1eEBGBMiW2I06Z A16jBwMlvXvn6zqurppCVHzwHa1O X-Google-Smtp-Source: APiQypKg7mXbMRx6lsjkDQqgPIHQZttFMx/idCYJxHaL9v+DTlHfl9elekOPAj/cIggD6d+WjHKk6g== X-Received: by 2002:a17:906:298f:: with SMTP id x15mr4967635eje.380.1586541096242; Fri, 10 Apr 2020 10:51:36 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k4sm177551ejj.63.2020.04.10.10.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 10:51:35 -0700 (PDT) Message-Id: <0d94eea376a65304bc31fd1841216a04b5c15709.1586541094.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Fri, 10 Apr 2020 17:51:32 +0000 Subject: [PATCH v2 1/3] rebase -i: mark commits that begin empty in todo editor Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: phillip.wood123@gmail.com, Johannes.Schindelin@gmx.de, bturner@atlassian.com, sami@boukortt.com, Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren While many users who intentionally create empty commits do not want them thrown away by a rebase, there are third-party tools that generate empty commits that a user might not want. In the past, users have used rebase to get rid of such commits (a side-effect of the fact that the --apply backend is not currently capable of keeping them). While such users could fire up an interactive rebase and just remove the lines corresponding to empty commits, that might be difficult if the third-party tool generates many of them. Simplify this task for users by marking such lines with a suffix of " # empty" in the todo list. Suggested-by: Sami Boukortt Signed-off-by: Elijah Newren --- Documentation/git-rebase.txt | 3 ++- sequencer.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index f7a6033607f..8ab0558aca2 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -620,7 +620,8 @@ commits that started empty, though these are rare in practice. It also drops commits that become empty and has no option for controlling this behavior. -The merge backend keeps intentionally empty commits. Similar to the +The merge backend keeps intentionally empty commits (though with -i +they are marked as empty in the todo list editor). Similar to the apply backend, by default the merge backend drops commits that become empty unless -i/--interactive is specified (in which case it stops and asks the user what to do). The merge backend also has an diff --git a/sequencer.c b/sequencer.c index e528225e787..ce9fd27a878 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4656,6 +4656,9 @@ static int make_script_with_merges(struct pretty_print_context *pp, strbuf_addf(&buf, "%s %s %s", cmd_pick, oid_to_hex(&commit->object.oid), oneline.buf); + if (is_empty) + strbuf_addf(&buf, " %c empty", + comment_line_char); FLEX_ALLOC_STR(entry, string, buf.buf); oidcpy(&entry->entry.oid, &commit->object.oid); @@ -4861,6 +4864,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc, strbuf_addf(out, "%s %s ", insn, oid_to_hex(&commit->object.oid)); pretty_print_commit(&pp, commit, out); + if (is_empty) + strbuf_addf(out, " %c empty", comment_line_char); strbuf_addch(out, '\n'); } return 0; From patchwork Fri Apr 10 17:51:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 11483517 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 0DA5415AB for ; Fri, 10 Apr 2020 17:51:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0B6D2082D for ; Fri, 10 Apr 2020 17:51:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NDHZkXnM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbgDJRvl (ORCPT ); Fri, 10 Apr 2020 13:51:41 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:35545 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726582AbgDJRvk (ORCPT ); Fri, 10 Apr 2020 13:51:40 -0400 Received: by mail-ed1-f67.google.com with SMTP id c7so3334462edl.2 for ; Fri, 10 Apr 2020 10:51:39 -0700 (PDT) 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=gWl/iWRa+0Hj+QnUOe1RWiSj/z2+1/SC7I+NNnKt1+M=; b=NDHZkXnM0f70hE+7b1Luh3wAvjDD3/623fyEGRs4ZiNEy/4gCcZMMaYvedqBoVEEX6 do0zEZt3xN+fPLA71kIHmrLubfq4nWfLMxKk8lbwvQo1qulathoRuhvNBXEI7xCLlCmV sX6bd+tUAlHltHzF6dB53P1lN8QVEECzp8HXtU53hcy/n7+6NjpoxpJL80ewmFfE43xy GoSvoz6Y6lJrzKM1CFllfesUCfkJkQpAoIQ0Fy8lt2KiW9IO63UtlwOLgbcp5Qid1uQz t2Z4kFR991Nl/vcEcI/7ZinHZcYOjSQ1HBp12vMyPaA5plBzspVL/eQquJLNZye7Ouzx pYaA== 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=gWl/iWRa+0Hj+QnUOe1RWiSj/z2+1/SC7I+NNnKt1+M=; b=AgbGkNKgi3YRJUHkGTTkTZ/xqid49VOvFIyrJiYhpe3EGr2xL1PutkSdAjkgd065R9 pcUEOEp29smRaRQa6998MUgZwhRpTuEW4uTIbfk2zdaYkdzUP2i6vlqrYaZdUIkTkoI3 z8A5v6JRPMEPTwCukTWUVkzbSl7m+3S4WCnxFY3h6HKhJsqPjTJ4vidZUvrtViw8TWeA F0O1i45U/F110/Tk2M6JzOxUdENdIwB9QOOd5/2H+K47u218Afl1UlfVzJkNv0AZusJr xFpf9S1xJs3AyzkV9iAn0Bkhblgeayr690PgQoABHQaAd6To10UrNkioTZWeqqdrvFKY 3TGQ== X-Gm-Message-State: AGi0PubirVlhnCbi4B8pkWGx32NCn9ECGVkuKifGqqlXKw8VIC+2EwMB k5kzIlkKlZQzAEHZFXFls9DmizYr X-Google-Smtp-Source: APiQypIxd+bEOXkMGfOI7tpyL4q+PGqT/FJTbwTbcC2kai4wbrCIsR4yg7TQIO3PSj85PPXBRKpYkQ== X-Received: by 2002:a17:906:2bcb:: with SMTP id n11mr5061655ejg.72.1586541098253; Fri, 10 Apr 2020 10:51:38 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m24sm164222edp.49.2020.04.10.10.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 10:51:37 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Fri, 10 Apr 2020 17:51:33 +0000 Subject: [PATCH v2 2/3] rebase: reinstate --no-keep-empty Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: phillip.wood123@gmail.com, Johannes.Schindelin@gmx.de, bturner@atlassian.com, sami@boukortt.com, Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren Commit d48e5e21da ("rebase (interactive-backend): make --keep-empty the default", 2020-02-15) turned --keep-empty (for keeping commits which start empty) into the default. That commit viewed this, though as turning that flag into a no-op. As such, --no-keep-empty was translated into undoing a no-op, i.e. also a no-op. The logic underpinning that commit was: 1) 'git commit' errors out on the creation of empty commits without an override flag 2) Once someone determines that the override is worthwhile, it's annoying and/or harmful to required them to take extra steps in order to keep such commits around (and to repeat such steps with every rebase). While the logic on which the decision was made is sound, the result was a bit of an overcorrection. Instead of jumping to having --keep-empty being the default, it jumped to making --keep-empty the only available behavior. There was a simple workaround, though, which was thought to be good enough at the time. People could still drop commits which started empty the same way the could drop any commits: by firing up an interactive rebase and picking out the commits they didn't want from the list. However, there are cases where external tools might create enough empty commits that picking all of them out is painful. As such, having a flag to automatically remove start-empty commits may be beneficial. Provide users a way to drop commits which start empty using a flag that existed for years: --no-keep-empty. Interpret --keep-empty as countermanding any previous --no-keep-empty, but otherwise leaving --keep-empty as the default. This might lead to some slight weirdness since commands like git rebase --empty=drop --keep-empty git rebase --empty=keep --no-keep-empty look really weird despite making perfect sense (the first will drop commits which become empty, but keep commits that started empty; the second will keep commits which become empty, but drop commits which started empty). Reported-by: Bryan Turner Reported-by: Sami Boukortt Signed-off-by: Elijah Newren --- Documentation/git-rebase.txt | 37 +++++++++++++++++-------------- builtin/rebase.c | 15 ++++++++----- sequencer.c | 6 +++++ sequencer.h | 2 +- t/t3421-rebase-topology-linear.sh | 10 ++++----- t/t3424-rebase-empty.sh | 36 ++++++++++++++++++++++++++++++ 6 files changed, 76 insertions(+), 30 deletions(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 8ab0558aca2..e58ca37786c 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -277,20 +277,21 @@ See also INCOMPATIBLE OPTIONS below. Other options, like --exec, will use the default of drop unless -i/--interactive is explicitly specified. + -Note that commits which start empty are kept, and commits which are -clean cherry-picks (as determined by `git log --cherry-mark ...`) are -always dropped. +Note that commits which start empty are kept (unless --no-keep-empty +is specified), and commits which are clean cherry-picks (as determined +by `git log --cherry-mark ...`) are detected and dropped as a preliminary +step (unless --keep-cherry-picks is passed). + See also INCOMPATIBLE OPTIONS below. +--no-keep-empty:: --keep-empty:: - No-op. Rebasing commits that started empty (had no change - relative to their parent) used to fail and this option would - override that behavior, allowing commits with empty changes to - be rebased. Now commits with no changes do not cause rebasing - to halt. + Do not keep commits that start empty before the rebase + (i.e. that do not change anything from its parent) in the + result. For commits which become empty after rebasing, see + the --empty and --keep-cherry-pick flags. + -See also BEHAVIORAL DIFFERENCES and INCOMPATIBLE OPTIONS below. +See also INCOMPATIBLE OPTIONS below. --allow-empty-message:: No-op. Rebasing commits with an empty message used to fail @@ -587,7 +588,7 @@ are incompatible with the following options: * --preserve-merges * --interactive * --exec - * --keep-empty + * --no-keep-empty * --empty= * --edit-todo * --root when used in combination with --onto @@ -620,13 +621,15 @@ commits that started empty, though these are rare in practice. It also drops commits that become empty and has no option for controlling this behavior. -The merge backend keeps intentionally empty commits (though with -i -they are marked as empty in the todo list editor). Similar to the -apply backend, by default the merge backend drops commits that become -empty unless -i/--interactive is specified (in which case it stops and -asks the user what to do). The merge backend also has an ---empty={drop,keep,ask} option for changing the behavior of handling -commits that become empty. +The merge backend keeps intentionally empty commits by default (though +with -i they are marked as empty in the todo list editor, or they can +be dropped automatically with --no-keep-empty). + +Similar to the apply backend, by default the merge backend drops +commits that become empty unless -i/--interactive is specified (in +which case it stops and asks the user what to do). The merge backend +also has an --empty={drop,keep,ask} option for changing the behavior +of handling commits that become empty. Directory rename detection ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/builtin/rebase.c b/builtin/rebase.c index bff53d5d167..022aa2589a5 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -85,6 +85,7 @@ struct rebase_options { const char *action; int signoff; int allow_rerere_autoupdate; + int keep_empty; int autosquash; char *gpg_sign_opt; int autostash; @@ -100,6 +101,7 @@ struct rebase_options { #define REBASE_OPTIONS_INIT { \ .type = REBASE_UNSPECIFIED, \ .empty = EMPTY_UNSPECIFIED, \ + .keep_empty = 1, \ .default_backend = "merge", \ .flags = REBASE_NO_QUIET, \ .git_am_opts = ARGV_ARRAY_INIT, \ @@ -379,6 +381,7 @@ static int run_sequencer_rebase(struct rebase_options *opts, git_config_get_bool("rebase.abbreviatecommands", &abbreviate_commands); + flags |= opts->keep_empty ? TODO_LIST_KEEP_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; @@ -442,6 +445,7 @@ static int run_sequencer_rebase(struct rebase_options *opts, return ret; } +static void imply_merge(struct rebase_options *opts, const char *option); static int parse_opt_keep_empty(const struct option *opt, const char *arg, int unset) { @@ -449,10 +453,8 @@ static int parse_opt_keep_empty(const struct option *opt, const char *arg, BUG_ON_OPT_ARG(arg); - /* - * If we ever want to remap --keep-empty to --empty=keep, insert: - * opts->empty = unset ? EMPTY_UNSPECIFIED : EMPTY_KEEP; - */ + imply_merge(opts, unset ? "--no-keep-empty" : "--keep-empty"); + opts->keep_empty = !unset; opts->type = REBASE_MERGE; return 0; } @@ -471,7 +473,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix) OPT_NEGBIT(0, "ff", &opts.flags, N_("allow fast-forward"), REBASE_FORCE), { OPTION_CALLBACK, 'k', "keep-empty", &options, NULL, - N_("(DEPRECATED) keep empty commits"), + N_("keep commits which start empty"), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, parse_opt_keep_empty }, OPT_BOOL_F(0, "allow-empty-message", &opts.allow_empty_message, @@ -1162,6 +1164,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, "autosquash", opts->autosquash ? "t" : ""); add_var(&script_snippet, "gpg_sign_opt", opts->gpg_sign_opt); add_var(&script_snippet, "cmd", opts->cmd); @@ -1547,7 +1550,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) N_("how to handle commits that become empty"), PARSE_OPT_NONEG, parse_opt_empty), { OPTION_CALLBACK, 'k', "keep-empty", &options, NULL, - N_("(DEPRECATED) keep empty commits"), + N_("keep commits which start empty"), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, parse_opt_keep_empty }, OPT_BOOL(0, "autosquash", &options.autosquash, diff --git a/sequencer.c b/sequencer.c index ce9fd27a878..d973e19729e 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4591,6 +4591,7 @@ 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 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; @@ -4645,6 +4646,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 && !keep_empty) + continue; strbuf_reset(&oneline); pretty_print_commit(pp, commit, &oneline); @@ -4822,6 +4825,7 @@ 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; const char *insn = flags & TODO_LIST_ABBREVIATE_CMDS ? "p" : "pick"; int rebase_merges = flags & TODO_LIST_REBASE_MERGES; @@ -4861,6 +4865,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc, if (!is_empty && (commit->object.flags & PATCHSAME)) continue; + if (is_empty && !keep_empty) + continue; strbuf_addf(out, "%s %s ", insn, oid_to_hex(&commit->object.oid)); pretty_print_commit(&pp, commit, out); diff --git a/sequencer.h b/sequencer.h index 718a07426da..7ebaa237340 100644 --- a/sequencer.h +++ b/sequencer.h @@ -134,7 +134,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) */ /* No longer used */ +#define TODO_LIST_KEEP_EMPTY (1U << 0) #define TODO_LIST_SHORTEN_IDS (1U << 1) #define TODO_LIST_ABBREVIATE_CMDS (1U << 2) #define TODO_LIST_REBASE_MERGES (1U << 3) diff --git a/t/t3421-rebase-topology-linear.sh b/t/t3421-rebase-topology-linear.sh index cf8dfd6c203..4a9204b4b64 100755 --- a/t/t3421-rebase-topology-linear.sh +++ b/t/t3421-rebase-topology-linear.sh @@ -220,14 +220,13 @@ test_have_prereq !REBASE_P || test_run_rebase failure -p test_run_rebase () { result=$1 shift - test_expect_$result "rebase $* --keep-empty" " + test_expect_$result "rebase $* --no-keep-empty drops begin-empty commits" " reset_rebase && - git rebase $* --keep-empty c l && - test_cmp_rev c HEAD~3 && - test_linear_range 'd k l' c.. + git rebase $* --no-keep-empty c l && + test_cmp_rev c HEAD~2 && + test_linear_range 'd l' c.. " } -test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p @@ -242,7 +241,6 @@ test_run_rebase () { test_linear_range 'd k l' j.. " } -test_run_rebase success --apply test_run_rebase success -m test_run_rebase success -i test_have_prereq !REBASE_P || test_run_rebase success -p diff --git a/t/t3424-rebase-empty.sh b/t/t3424-rebase-empty.sh index e1e30517ea6..5e1045a0afc 100755 --- a/t/t3424-rebase-empty.sh +++ b/t/t3424-rebase-empty.sh @@ -123,6 +123,42 @@ test_expect_success 'rebase --interactive uses default of --empty=ask' ' test_cmp expect actual ' +test_expect_success 'rebase --merge --empty=drop --keep-empty' ' + git checkout -B testing localmods && + git rebase --merge --empty=drop --keep-empty upstream && + + test_write_lines D C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --merge --empty=drop --no-keep-empty' ' + git checkout -B testing localmods && + git rebase --merge --empty=drop --no-keep-empty upstream && + + test_write_lines C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + +test_expect_success 'rebase --merge --empty=keep --keep-empty' ' + git checkout -B testing localmods && + git rebase --merge --empty=keep --keep-empty 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=keep --no-keep-empty' ' + git checkout -B testing localmods && + git rebase --merge --empty=keep --no-keep-empty upstream && + + test_write_lines C2 C B A >expect && + git log --format=%s >actual && + test_cmp expect actual +' + test_expect_success 'rebase --merge does not leave state laying around' ' git checkout -B testing localmods~2 && git rebase --merge upstream && From patchwork Fri Apr 10 17:51:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 11483521 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 F12FF15AB for ; Fri, 10 Apr 2020 17:51:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3AE52087E for ; Fri, 10 Apr 2020 17:51:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bvrPNDBt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726721AbgDJRvn (ORCPT ); Fri, 10 Apr 2020 13:51:43 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:33227 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgDJRvm (ORCPT ); Fri, 10 Apr 2020 13:51:42 -0400 Received: by mail-ed1-f66.google.com with SMTP id z65so3364441ede.0 for ; Fri, 10 Apr 2020 10:51:40 -0700 (PDT) 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=uKuuHJEYmJLprzJwDK7aADJABshMqhpuzDAb3cVwbSs=; b=bvrPNDBtruJ/aY7YvKYWzYKAkSPH5U19LowgP8wV9rb74rzISCh7tBSkKE9EnT+XS+ 2EqfYZPzDBI4wKwZ1DFUPx9uFpJMApH8nsF9Wi/fMNMDQN4Vkc8UYCAavcSIHVVLXdHO k/rE76RSGEWPEn7s+1BqoALQVpbGeJV4PfCqUuAqQ3poOarEBTaQL7VHE/U0jzWAN/A+ ACibONQY7whKAbrt7yknzuMMggvyp65FglCG9bLmV2a50Cc/rYy95cV0kraiSEB3SZBl 8zWqsqePPjm9mSkQCQlzAQ2419/lav8mvZLFv+9F2OGWa2FJOpwP+PISywChKrVoMMn7 7F1g== 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=uKuuHJEYmJLprzJwDK7aADJABshMqhpuzDAb3cVwbSs=; b=TifvDagFf4HGXD4fkPHewXsl6x1qNJ6LW5YMdIZlov07CEcMG5W6R+GCBb+4WjUuMD hm/mqH2OjNW7IZCyK3+iHNw3ZRz76sE6oR6wS8dk6vB/eVuMyZWXZOYIceWX2nkIlJ2x XOZjfzDdDAvOtERMhEh9tE/x3wYMLo4HR6x5h1VIxvcI+Oe5+5KYMYt+fx8L74CMrJj7 CX2GyK10v6yJfzjoZChi66aQDD3zUTd7zTQZJnHkFctdJMbTLMOkBPJ5DDVmB3p/hG4o +8GWtq9+MZUPUYq3EF3Dkiu4eIrJVu3ixf5tux94nJt2iqNQzdRScyBciN6Ldg4r35nx ktvw== X-Gm-Message-State: AGi0PuabiT9MUptzO6XPEXD3/KZUymdjBprNQauinlkN6TRr+7EkaioV BA1Y/wdiYJA6YhPl/HpuuKolrIN6 X-Google-Smtp-Source: APiQypKOQbH9YGtnQ+RIH90gv77nHYN78ziYm+n89iaH2KWDcVpzl4hn7t23XULnGkYujxL9/BDePg== X-Received: by 2002:a17:906:9494:: with SMTP id t20mr4382269ejx.51.1586541099033; Fri, 10 Apr 2020 10:51:39 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m18sm154606eda.14.2020.04.10.10.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 10:51:38 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Elijah Newren via GitGitGadget" Date: Fri, 10 Apr 2020 17:51:34 +0000 Subject: [PATCH v2 3/3] rebase: fix an incompatible-options error message Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: phillip.wood123@gmail.com, Johannes.Schindelin@gmx.de, bturner@atlassian.com, sami@boukortt.com, Elijah Newren , Elijah Newren Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren When the user specifies the apply backend with options that only work with the merge backend, such as git rebase --apply --exec /bin/true HEAD~3 the error message has always been fatal: --exec requires an interactive rebase This error message is misleading and was one of the reasons we renamed the interactive backend to the merge backend. Update the error message to state that these options merely require use of the merge backend. Signed-off-by: Elijah Newren --- builtin/rebase.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 022aa2589a5..0e223a96d46 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -561,7 +561,7 @@ static void imply_merge(struct rebase_options *opts, const char *option) { switch (opts->type) { case REBASE_APPLY: - die(_("%s requires an interactive rebase"), option); + die(_("%s requires the merge backend"), option); break; case REBASE_MERGE: case REBASE_PRESERVE_MERGES: