rebase: drop support for --preserve-merges
This option was deprecated in favor of `--rebase-merges` some time ago, and now we retire it. To assist users to transition away, we do not _actually_ remove the option, but now we no longer implement the functionality. Instead, we offer a helpful error message suggesting which option to use. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
52f1e82178
commit
a74b35081c
1
.gitignore
vendored
1
.gitignore
vendored
@ -125,7 +125,6 @@
|
||||
/git-range-diff
|
||||
/git-read-tree
|
||||
/git-rebase
|
||||
/git-rebase--preserve-merges
|
||||
/git-receive-pack
|
||||
/git-reflog
|
||||
/git-remote
|
||||
|
@ -525,29 +525,12 @@ i.e. commits that would be excluded by linkgit:git-log[1]'s
|
||||
the `rebase-cousins` mode is turned on, such commits are instead rebased
|
||||
onto `<upstream>` (or `<onto>`, if specified).
|
||||
+
|
||||
The `--rebase-merges` mode is similar in spirit to the deprecated
|
||||
`--preserve-merges` but works with interactive rebases,
|
||||
where commits can be reordered, inserted and dropped at will.
|
||||
+
|
||||
It is currently only possible to recreate the merge commits using the
|
||||
`recursive` merge strategy; Different merge strategies can be used only via
|
||||
explicit `exec git merge -s <strategy> [...]` commands.
|
||||
+
|
||||
See also REBASING MERGES and INCOMPATIBLE OPTIONS below.
|
||||
|
||||
-p::
|
||||
--preserve-merges::
|
||||
[DEPRECATED: use `--rebase-merges` instead] Recreate merge commits
|
||||
instead of flattening the history by replaying commits a merge commit
|
||||
introduces. Merge conflict resolutions or manual amendments to merge
|
||||
commits are not preserved.
|
||||
+
|
||||
This uses the `--interactive` machinery internally, but combining it
|
||||
with the `--interactive` option explicitly is generally not a good
|
||||
idea unless you know what you are doing (see BUGS below).
|
||||
+
|
||||
See also INCOMPATIBLE OPTIONS below.
|
||||
|
||||
-x <cmd>::
|
||||
--exec <cmd>::
|
||||
Append "exec <cmd>" after each line creating a commit in the
|
||||
@ -579,9 +562,6 @@ See also INCOMPATIBLE OPTIONS below.
|
||||
the root commit(s) on a branch. When used with --onto, it
|
||||
will skip changes already contained in <newbase> (instead of
|
||||
<upstream>) whereas without --onto it will operate on every change.
|
||||
When used together with both --onto and --preserve-merges,
|
||||
'all' root commits will be rewritten to have <newbase> as parent
|
||||
instead.
|
||||
+
|
||||
See also INCOMPATIBLE OPTIONS below.
|
||||
|
||||
@ -643,7 +623,6 @@ are incompatible with the following options:
|
||||
* --allow-empty-message
|
||||
* --[no-]autosquash
|
||||
* --rebase-merges
|
||||
* --preserve-merges
|
||||
* --interactive
|
||||
* --exec
|
||||
* --no-keep-empty
|
||||
@ -654,13 +633,6 @@ are incompatible with the following options:
|
||||
|
||||
In addition, the following pairs of options are incompatible:
|
||||
|
||||
* --preserve-merges and --interactive
|
||||
* --preserve-merges and --signoff
|
||||
* --preserve-merges and --rebase-merges
|
||||
* --preserve-merges and --empty=
|
||||
* --preserve-merges and --ignore-whitespace
|
||||
* --preserve-merges and --committer-date-is-author-date
|
||||
* --preserve-merges and --ignore-date
|
||||
* --keep-base and --onto
|
||||
* --keep-base and --root
|
||||
* --fork-point and --root
|
||||
@ -1274,29 +1246,6 @@ CONFIGURATION
|
||||
include::config/rebase.txt[]
|
||||
include::config/sequencer.txt[]
|
||||
|
||||
BUGS
|
||||
----
|
||||
The todo list presented by the deprecated `--preserve-merges --interactive`
|
||||
does not represent the topology of the revision graph (use `--rebase-merges`
|
||||
instead). Editing commits and rewording their commit messages should work
|
||||
fine, but attempts to reorder commits tend to produce counterintuitive results.
|
||||
Use `--rebase-merges` in such scenarios instead.
|
||||
|
||||
For example, an attempt to rearrange
|
||||
------------
|
||||
1 --- 2 --- 3 --- 4 --- 5
|
||||
------------
|
||||
to
|
||||
------------
|
||||
1 --- 2 --- 4 --- 3 --- 5
|
||||
------------
|
||||
by moving the "pick 4" line will result in the following history:
|
||||
------------
|
||||
3
|
||||
/
|
||||
1 --- 2 --- 4 --- 5
|
||||
------------
|
||||
|
||||
GIT
|
||||
---
|
||||
Part of the linkgit:git[1] suite
|
||||
|
2
Makefile
2
Makefile
@ -616,7 +616,6 @@ SCRIPT_SH += git-submodule.sh
|
||||
SCRIPT_SH += git-web--browse.sh
|
||||
|
||||
SCRIPT_LIB += git-mergetool--lib
|
||||
SCRIPT_LIB += git-rebase--preserve-merges
|
||||
SCRIPT_LIB += git-sh-i18n
|
||||
SCRIPT_LIB += git-sh-setup
|
||||
|
||||
@ -2649,7 +2648,6 @@ XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
|
||||
--keyword=__ --keyword=N__ --keyword="__n:1,2"
|
||||
LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
|
||||
LOCALIZED_SH = $(SCRIPT_SH)
|
||||
LOCALIZED_SH += git-rebase--preserve-merges.sh
|
||||
LOCALIZED_SH += git-sh-setup.sh
|
||||
LOCALIZED_PERL = $(SCRIPT_PERL)
|
||||
|
||||
|
138
builtin/rebase.c
138
builtin/rebase.c
@ -48,8 +48,7 @@ static GIT_PATH_FUNC(merge_dir, "rebase-merge")
|
||||
enum rebase_type {
|
||||
REBASE_UNSPECIFIED = -1,
|
||||
REBASE_APPLY,
|
||||
REBASE_MERGE,
|
||||
REBASE_PRESERVE_MERGES
|
||||
REBASE_MERGE
|
||||
};
|
||||
|
||||
enum empty_type {
|
||||
@ -571,8 +570,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
|
||||
|
||||
static int is_merge(struct rebase_options *opts)
|
||||
{
|
||||
return opts->type == REBASE_MERGE ||
|
||||
opts->type == REBASE_PRESERVE_MERGES;
|
||||
return opts->type == REBASE_MERGE;
|
||||
}
|
||||
|
||||
static void imply_merge(struct rebase_options *opts, const char *option)
|
||||
@ -582,7 +580,6 @@ static void imply_merge(struct rebase_options *opts, const char *option)
|
||||
die(_("%s requires the merge backend"), option);
|
||||
break;
|
||||
case REBASE_MERGE:
|
||||
case REBASE_PRESERVE_MERGES:
|
||||
break;
|
||||
default:
|
||||
opts->type = REBASE_MERGE; /* implied */
|
||||
@ -773,17 +770,6 @@ static struct commit *peel_committish(const char *name)
|
||||
return (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
|
||||
}
|
||||
|
||||
static void add_var(struct strbuf *buf, const char *name, const char *value)
|
||||
{
|
||||
if (!value)
|
||||
strbuf_addf(buf, "unset %s; ", name);
|
||||
else {
|
||||
strbuf_addf(buf, "%s=", name);
|
||||
sq_quote_buf(buf, value);
|
||||
strbuf_addstr(buf, "; ");
|
||||
}
|
||||
}
|
||||
|
||||
static int move_to_original_branch(struct rebase_options *opts)
|
||||
{
|
||||
struct strbuf orig_head_reflog = STRBUF_INIT, head_reflog = STRBUF_INIT;
|
||||
@ -940,10 +926,7 @@ static int run_am(struct rebase_options *opts)
|
||||
|
||||
static int run_specific_rebase(struct rebase_options *opts, enum action action)
|
||||
{
|
||||
const char *argv[] = { NULL, NULL };
|
||||
struct strbuf script_snippet = STRBUF_INIT, buf = STRBUF_INIT;
|
||||
int status;
|
||||
const char *backend, *backend_func;
|
||||
|
||||
if (opts->type == REBASE_MERGE) {
|
||||
/* Run sequencer-based rebase */
|
||||
@ -960,87 +943,11 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
|
||||
}
|
||||
|
||||
status = run_sequencer_rebase(opts, action);
|
||||
goto finished_rebase;
|
||||
}
|
||||
|
||||
if (opts->type == REBASE_APPLY) {
|
||||
} else if (opts->type == REBASE_APPLY)
|
||||
status = run_am(opts);
|
||||
goto finished_rebase;
|
||||
}
|
||||
|
||||
add_var(&script_snippet, "GIT_DIR", absolute_path(get_git_dir()));
|
||||
add_var(&script_snippet, "state_dir", opts->state_dir);
|
||||
|
||||
add_var(&script_snippet, "upstream_name", opts->upstream_name);
|
||||
add_var(&script_snippet, "upstream", opts->upstream ?
|
||||
oid_to_hex(&opts->upstream->object.oid) : NULL);
|
||||
add_var(&script_snippet, "head_name",
|
||||
opts->head_name ? opts->head_name : "detached HEAD");
|
||||
add_var(&script_snippet, "orig_head", oid_to_hex(&opts->orig_head));
|
||||
add_var(&script_snippet, "onto", opts->onto ?
|
||||
oid_to_hex(&opts->onto->object.oid) : NULL);
|
||||
add_var(&script_snippet, "onto_name", opts->onto_name);
|
||||
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);
|
||||
sq_quote_argv_pretty(&buf, opts->git_am_opts.v);
|
||||
add_var(&script_snippet, "git_am_opt", buf.buf);
|
||||
strbuf_release(&buf);
|
||||
add_var(&script_snippet, "verbose",
|
||||
opts->flags & REBASE_VERBOSE ? "t" : "");
|
||||
add_var(&script_snippet, "diffstat",
|
||||
opts->flags & REBASE_DIFFSTAT ? "t" : "");
|
||||
add_var(&script_snippet, "force_rebase",
|
||||
opts->flags & REBASE_FORCE ? "t" : "");
|
||||
if (opts->switch_to)
|
||||
add_var(&script_snippet, "switch_to", opts->switch_to);
|
||||
add_var(&script_snippet, "action", opts->action ? opts->action : "");
|
||||
add_var(&script_snippet, "signoff", opts->signoff ? "--signoff" : "");
|
||||
add_var(&script_snippet, "allow_rerere_autoupdate",
|
||||
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);
|
||||
add_var(&script_snippet, "allow_empty_message",
|
||||
opts->allow_empty_message ? "--allow-empty-message" : "");
|
||||
add_var(&script_snippet, "rebase_merges",
|
||||
opts->rebase_merges ? "t" : "");
|
||||
add_var(&script_snippet, "rebase_cousins",
|
||||
opts->rebase_cousins ? "t" : "");
|
||||
add_var(&script_snippet, "strategy", opts->strategy);
|
||||
add_var(&script_snippet, "strategy_opts", opts->strategy_opts);
|
||||
add_var(&script_snippet, "rebase_root", opts->root ? "t" : "");
|
||||
add_var(&script_snippet, "squash_onto",
|
||||
opts->squash_onto ? oid_to_hex(opts->squash_onto) : "");
|
||||
add_var(&script_snippet, "git_format_patch_opt",
|
||||
opts->git_format_patch_opt.buf);
|
||||
|
||||
if (is_merge(opts) &&
|
||||
!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
|
||||
strbuf_addstr(&script_snippet,
|
||||
"GIT_SEQUENCE_EDITOR=:; export GIT_SEQUENCE_EDITOR; ");
|
||||
opts->autosquash = 0;
|
||||
}
|
||||
|
||||
switch (opts->type) {
|
||||
case REBASE_PRESERVE_MERGES:
|
||||
backend = "git-rebase--preserve-merges";
|
||||
backend_func = "git_rebase__preserve_merges";
|
||||
break;
|
||||
default:
|
||||
else
|
||||
BUG("Unhandled rebase type %d", opts->type);
|
||||
break;
|
||||
}
|
||||
|
||||
strbuf_addf(&script_snippet,
|
||||
". git-sh-setup && . %s && %s", backend, backend_func);
|
||||
argv[0] = script_snippet.buf;
|
||||
|
||||
status = run_command_v_opt(argv, RUN_USING_SHELL);
|
||||
finished_rebase:
|
||||
if (opts->dont_finish_rebase)
|
||||
; /* do nothing */
|
||||
else if (opts->type == REBASE_MERGE)
|
||||
@ -1058,8 +965,6 @@ finished_rebase:
|
||||
die("Nothing to do");
|
||||
}
|
||||
|
||||
strbuf_release(&script_snippet);
|
||||
|
||||
return status ? -1 : 0;
|
||||
}
|
||||
|
||||
@ -1313,6 +1218,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
char *squash_onto_name = NULL;
|
||||
int reschedule_failed_exec = -1;
|
||||
int allow_preemptive_ff = 1;
|
||||
int preserve_merges_selected = 0;
|
||||
struct option builtin_rebase_options[] = {
|
||||
OPT_STRING(0, "onto", &options.onto_name,
|
||||
N_("revision"),
|
||||
@ -1377,10 +1283,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
N_("let the user edit the list of commits to rebase"),
|
||||
PARSE_OPT_NOARG | PARSE_OPT_NONEG,
|
||||
parse_opt_interactive),
|
||||
OPT_SET_INT_F('p', "preserve-merges", &options.type,
|
||||
OPT_SET_INT_F('p', "preserve-merges", &preserve_merges_selected,
|
||||
N_("(DEPRECATED) try to recreate merges instead of "
|
||||
"ignoring them"),
|
||||
REBASE_PRESERVE_MERGES, PARSE_OPT_HIDDEN),
|
||||
1, PARSE_OPT_HIDDEN),
|
||||
OPT_RERERE_AUTOUPDATE(&options.allow_rerere_autoupdate),
|
||||
OPT_CALLBACK_F(0, "empty", &options, "{drop,keep,ask}",
|
||||
N_("how to handle commits that become empty"),
|
||||
@ -1448,8 +1354,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
strbuf_reset(&buf);
|
||||
strbuf_addf(&buf, "%s/rewritten", merge_dir());
|
||||
if (is_directory(buf.buf)) {
|
||||
options.type = REBASE_PRESERVE_MERGES;
|
||||
options.flags |= REBASE_INTERACTIVE_EXPLICIT;
|
||||
die("`rebase -p` is no longer supported");
|
||||
} else {
|
||||
strbuf_reset(&buf);
|
||||
strbuf_addf(&buf, "%s/interactive", merge_dir());
|
||||
@ -1470,6 +1375,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
builtin_rebase_options,
|
||||
builtin_rebase_usage, 0);
|
||||
|
||||
if (preserve_merges_selected)
|
||||
die(_("--preserve-merges was replaced by --rebase-merges"));
|
||||
|
||||
if (action != ACTION_NONE && total_argc != 2) {
|
||||
usage_with_options(builtin_rebase_usage,
|
||||
builtin_rebase_options);
|
||||
@ -1479,10 +1387,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
usage_with_options(builtin_rebase_usage,
|
||||
builtin_rebase_options);
|
||||
|
||||
if (options.type == REBASE_PRESERVE_MERGES)
|
||||
warning(_("git rebase --preserve-merges is deprecated. "
|
||||
"Use --rebase-merges instead."));
|
||||
|
||||
if (keep_base) {
|
||||
if (options.onto_name)
|
||||
die(_("cannot combine '--keep-base' with '--onto'"));
|
||||
@ -1728,7 +1632,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
case REBASE_APPLY:
|
||||
die(_("--strategy requires --merge or --interactive"));
|
||||
case REBASE_MERGE:
|
||||
case REBASE_PRESERVE_MERGES:
|
||||
/* compatible */
|
||||
break;
|
||||
case REBASE_UNSPECIFIED:
|
||||
@ -1780,7 +1683,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
|
||||
switch (options.type) {
|
||||
case REBASE_MERGE:
|
||||
case REBASE_PRESERVE_MERGES:
|
||||
options.state_dir = merge_dir();
|
||||
break;
|
||||
case REBASE_APPLY:
|
||||
@ -1805,28 +1707,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||
options.reschedule_failed_exec = reschedule_failed_exec;
|
||||
|
||||
if (options.signoff) {
|
||||
if (options.type == REBASE_PRESERVE_MERGES)
|
||||
die("cannot combine '--signoff' with "
|
||||
"'--preserve-merges'");
|
||||
strvec_push(&options.git_am_opts, "--signoff");
|
||||
options.flags |= REBASE_FORCE;
|
||||
}
|
||||
|
||||
if (options.type == REBASE_PRESERVE_MERGES) {
|
||||
/*
|
||||
* Note: incompatibility with --signoff handled in signoff block above
|
||||
* Note: incompatibility with --interactive is just a strong warning;
|
||||
* git-rebase.txt caveats with "unless you know what you are doing"
|
||||
*/
|
||||
if (options.rebase_merges)
|
||||
die(_("cannot combine '--preserve-merges' with "
|
||||
"'--rebase-merges'"));
|
||||
|
||||
if (options.reschedule_failed_exec)
|
||||
die(_("error: cannot combine '--preserve-merges' with "
|
||||
"'--reschedule-failed-exec'"));
|
||||
}
|
||||
|
||||
if (!options.root) {
|
||||
if (argc < 1) {
|
||||
struct branch *branch;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user