Skip to content

Commit a74b350

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Reviewed-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 52f1e82 commit a74b350

File tree

5 files changed

+11
-1238
lines changed

5 files changed

+11
-1238
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@
125125
/git-range-diff
126126
/git-read-tree
127127
/git-rebase
128-
/git-rebase--preserve-merges
129128
/git-receive-pack
130129
/git-reflog
131130
/git-remote

Documentation/git-rebase.txt

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -525,29 +525,12 @@ i.e. commits that would be excluded by linkgit:git-log[1]'s
525525
the `rebase-cousins` mode is turned on, such commits are instead rebased
526526
onto `<upstream>` (or `<onto>`, if specified).
527527
+
528-
The `--rebase-merges` mode is similar in spirit to the deprecated
529-
`--preserve-merges` but works with interactive rebases,
530-
where commits can be reordered, inserted and dropped at will.
531-
+
532528
It is currently only possible to recreate the merge commits using the
533529
`recursive` merge strategy; Different merge strategies can be used only via
534530
explicit `exec git merge -s <strategy> [...]` commands.
535531
+
536532
See also REBASING MERGES and INCOMPATIBLE OPTIONS below.
537533

538-
-p::
539-
--preserve-merges::
540-
[DEPRECATED: use `--rebase-merges` instead] Recreate merge commits
541-
instead of flattening the history by replaying commits a merge commit
542-
introduces. Merge conflict resolutions or manual amendments to merge
543-
commits are not preserved.
544-
+
545-
This uses the `--interactive` machinery internally, but combining it
546-
with the `--interactive` option explicitly is generally not a good
547-
idea unless you know what you are doing (see BUGS below).
548-
+
549-
See also INCOMPATIBLE OPTIONS below.
550-
551534
-x <cmd>::
552535
--exec <cmd>::
553536
Append "exec <cmd>" after each line creating a commit in the
@@ -579,9 +562,6 @@ See also INCOMPATIBLE OPTIONS below.
579562
the root commit(s) on a branch. When used with --onto, it
580563
will skip changes already contained in <newbase> (instead of
581564
<upstream>) whereas without --onto it will operate on every change.
582-
When used together with both --onto and --preserve-merges,
583-
'all' root commits will be rewritten to have <newbase> as parent
584-
instead.
585565
+
586566
See also INCOMPATIBLE OPTIONS below.
587567

@@ -643,7 +623,6 @@ are incompatible with the following options:
643623
* --allow-empty-message
644624
* --[no-]autosquash
645625
* --rebase-merges
646-
* --preserve-merges
647626
* --interactive
648627
* --exec
649628
* --no-keep-empty
@@ -654,13 +633,6 @@ are incompatible with the following options:
654633

655634
In addition, the following pairs of options are incompatible:
656635

657-
* --preserve-merges and --interactive
658-
* --preserve-merges and --signoff
659-
* --preserve-merges and --rebase-merges
660-
* --preserve-merges and --empty=
661-
* --preserve-merges and --ignore-whitespace
662-
* --preserve-merges and --committer-date-is-author-date
663-
* --preserve-merges and --ignore-date
664636
* --keep-base and --onto
665637
* --keep-base and --root
666638
* --fork-point and --root
@@ -1274,29 +1246,6 @@ CONFIGURATION
12741246
include::config/rebase.txt[]
12751247
include::config/sequencer.txt[]
12761248

1277-
BUGS
1278-
----
1279-
The todo list presented by the deprecated `--preserve-merges --interactive`
1280-
does not represent the topology of the revision graph (use `--rebase-merges`
1281-
instead). Editing commits and rewording their commit messages should work
1282-
fine, but attempts to reorder commits tend to produce counterintuitive results.
1283-
Use `--rebase-merges` in such scenarios instead.
1284-
1285-
For example, an attempt to rearrange
1286-
------------
1287-
1 --- 2 --- 3 --- 4 --- 5
1288-
------------
1289-
to
1290-
------------
1291-
1 --- 2 --- 4 --- 3 --- 5
1292-
------------
1293-
by moving the "pick 4" line will result in the following history:
1294-
------------
1295-
3
1296-
/
1297-
1 --- 2 --- 4 --- 5
1298-
------------
1299-
13001249
GIT
13011250
---
13021251
Part of the linkgit:git[1] suite

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ SCRIPT_SH += git-submodule.sh
616616
SCRIPT_SH += git-web--browse.sh
617617

618618
SCRIPT_LIB += git-mergetool--lib
619-
SCRIPT_LIB += git-rebase--preserve-merges
620619
SCRIPT_LIB += git-sh-i18n
621620
SCRIPT_LIB += git-sh-setup
622621

@@ -2649,7 +2648,6 @@ XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
26492648
--keyword=__ --keyword=N__ --keyword="__n:1,2"
26502649
LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
26512650
LOCALIZED_SH = $(SCRIPT_SH)
2652-
LOCALIZED_SH += git-rebase--preserve-merges.sh
26532651
LOCALIZED_SH += git-sh-setup.sh
26542652
LOCALIZED_PERL = $(SCRIPT_PERL)
26552653

builtin/rebase.c

Lines changed: 11 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ static GIT_PATH_FUNC(merge_dir, "rebase-merge")
4848
enum rebase_type {
4949
REBASE_UNSPECIFIED = -1,
5050
REBASE_APPLY,
51-
REBASE_MERGE,
52-
REBASE_PRESERVE_MERGES
51+
REBASE_MERGE
5352
};
5453

5554
enum empty_type {
@@ -571,8 +570,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
571570

572571
static int is_merge(struct rebase_options *opts)
573572
{
574-
return opts->type == REBASE_MERGE ||
575-
opts->type == REBASE_PRESERVE_MERGES;
573+
return opts->type == REBASE_MERGE;
576574
}
577575

578576
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)
582580
die(_("%s requires the merge backend"), option);
583581
break;
584582
case REBASE_MERGE:
585-
case REBASE_PRESERVE_MERGES:
586583
break;
587584
default:
588585
opts->type = REBASE_MERGE; /* implied */
@@ -773,17 +770,6 @@ static struct commit *peel_committish(const char *name)
773770
return (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT);
774771
}
775772

776-
static void add_var(struct strbuf *buf, const char *name, const char *value)
777-
{
778-
if (!value)
779-
strbuf_addf(buf, "unset %s; ", name);
780-
else {
781-
strbuf_addf(buf, "%s=", name);
782-
sq_quote_buf(buf, value);
783-
strbuf_addstr(buf, "; ");
784-
}
785-
}
786-
787773
static int move_to_original_branch(struct rebase_options *opts)
788774
{
789775
struct strbuf orig_head_reflog = STRBUF_INIT, head_reflog = STRBUF_INIT;
@@ -940,10 +926,7 @@ static int run_am(struct rebase_options *opts)
940926

941927
static int run_specific_rebase(struct rebase_options *opts, enum action action)
942928
{
943-
const char *argv[] = { NULL, NULL };
944-
struct strbuf script_snippet = STRBUF_INIT, buf = STRBUF_INIT;
945929
int status;
946-
const char *backend, *backend_func;
947930

948931
if (opts->type == REBASE_MERGE) {
949932
/* Run sequencer-based rebase */
@@ -960,87 +943,11 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
960943
}
961944

962945
status = run_sequencer_rebase(opts, action);
963-
goto finished_rebase;
964-
}
965-
966-
if (opts->type == REBASE_APPLY) {
946+
} else if (opts->type == REBASE_APPLY)
967947
status = run_am(opts);
968-
goto finished_rebase;
969-
}
970-
971-
add_var(&script_snippet, "GIT_DIR", absolute_path(get_git_dir()));
972-
add_var(&script_snippet, "state_dir", opts->state_dir);
973-
974-
add_var(&script_snippet, "upstream_name", opts->upstream_name);
975-
add_var(&script_snippet, "upstream", opts->upstream ?
976-
oid_to_hex(&opts->upstream->object.oid) : NULL);
977-
add_var(&script_snippet, "head_name",
978-
opts->head_name ? opts->head_name : "detached HEAD");
979-
add_var(&script_snippet, "orig_head", oid_to_hex(&opts->orig_head));
980-
add_var(&script_snippet, "onto", opts->onto ?
981-
oid_to_hex(&opts->onto->object.oid) : NULL);
982-
add_var(&script_snippet, "onto_name", opts->onto_name);
983-
add_var(&script_snippet, "revisions", opts->revisions);
984-
add_var(&script_snippet, "restrict_revision", opts->restrict_revision ?
985-
oid_to_hex(&opts->restrict_revision->object.oid) : NULL);
986-
sq_quote_argv_pretty(&buf, opts->git_am_opts.v);
987-
add_var(&script_snippet, "git_am_opt", buf.buf);
988-
strbuf_release(&buf);
989-
add_var(&script_snippet, "verbose",
990-
opts->flags & REBASE_VERBOSE ? "t" : "");
991-
add_var(&script_snippet, "diffstat",
992-
opts->flags & REBASE_DIFFSTAT ? "t" : "");
993-
add_var(&script_snippet, "force_rebase",
994-
opts->flags & REBASE_FORCE ? "t" : "");
995-
if (opts->switch_to)
996-
add_var(&script_snippet, "switch_to", opts->switch_to);
997-
add_var(&script_snippet, "action", opts->action ? opts->action : "");
998-
add_var(&script_snippet, "signoff", opts->signoff ? "--signoff" : "");
999-
add_var(&script_snippet, "allow_rerere_autoupdate",
1000-
opts->allow_rerere_autoupdate ?
1001-
opts->allow_rerere_autoupdate == RERERE_AUTOUPDATE ?
1002-
"--rerere-autoupdate" : "--no-rerere-autoupdate" : "");
1003-
add_var(&script_snippet, "keep_empty", opts->keep_empty ? "yes" : "");
1004-
add_var(&script_snippet, "autosquash", opts->autosquash ? "t" : "");
1005-
add_var(&script_snippet, "gpg_sign_opt", opts->gpg_sign_opt);
1006-
add_var(&script_snippet, "cmd", opts->cmd);
1007-
add_var(&script_snippet, "allow_empty_message",
1008-
opts->allow_empty_message ? "--allow-empty-message" : "");
1009-
add_var(&script_snippet, "rebase_merges",
1010-
opts->rebase_merges ? "t" : "");
1011-
add_var(&script_snippet, "rebase_cousins",
1012-
opts->rebase_cousins ? "t" : "");
1013-
add_var(&script_snippet, "strategy", opts->strategy);
1014-
add_var(&script_snippet, "strategy_opts", opts->strategy_opts);
1015-
add_var(&script_snippet, "rebase_root", opts->root ? "t" : "");
1016-
add_var(&script_snippet, "squash_onto",
1017-
opts->squash_onto ? oid_to_hex(opts->squash_onto) : "");
1018-
add_var(&script_snippet, "git_format_patch_opt",
1019-
opts->git_format_patch_opt.buf);
1020-
1021-
if (is_merge(opts) &&
1022-
!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
1023-
strbuf_addstr(&script_snippet,
1024-
"GIT_SEQUENCE_EDITOR=:; export GIT_SEQUENCE_EDITOR; ");
1025-
opts->autosquash = 0;
1026-
}
1027-
1028-
switch (opts->type) {
1029-
case REBASE_PRESERVE_MERGES:
1030-
backend = "git-rebase--preserve-merges";
1031-
backend_func = "git_rebase__preserve_merges";
1032-
break;
1033-
default:
948+
else
1034949
BUG("Unhandled rebase type %d", opts->type);
1035-
break;
1036-
}
1037-
1038-
strbuf_addf(&script_snippet,
1039-
". git-sh-setup && . %s && %s", backend, backend_func);
1040-
argv[0] = script_snippet.buf;
1041950

1042-
status = run_command_v_opt(argv, RUN_USING_SHELL);
1043-
finished_rebase:
1044951
if (opts->dont_finish_rebase)
1045952
; /* do nothing */
1046953
else if (opts->type == REBASE_MERGE)
@@ -1058,8 +965,6 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
1058965
die("Nothing to do");
1059966
}
1060967

1061-
strbuf_release(&script_snippet);
1062-
1063968
return status ? -1 : 0;
1064969
}
1065970

@@ -1313,6 +1218,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
13131218
char *squash_onto_name = NULL;
13141219
int reschedule_failed_exec = -1;
13151220
int allow_preemptive_ff = 1;
1221+
int preserve_merges_selected = 0;
13161222
struct option builtin_rebase_options[] = {
13171223
OPT_STRING(0, "onto", &options.onto_name,
13181224
N_("revision"),
@@ -1377,10 +1283,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
13771283
N_("let the user edit the list of commits to rebase"),
13781284
PARSE_OPT_NOARG | PARSE_OPT_NONEG,
13791285
parse_opt_interactive),
1380-
OPT_SET_INT_F('p', "preserve-merges", &options.type,
1286+
OPT_SET_INT_F('p', "preserve-merges", &preserve_merges_selected,
13811287
N_("(DEPRECATED) try to recreate merges instead of "
13821288
"ignoring them"),
1383-
REBASE_PRESERVE_MERGES, PARSE_OPT_HIDDEN),
1289+
1, PARSE_OPT_HIDDEN),
13841290
OPT_RERERE_AUTOUPDATE(&options.allow_rerere_autoupdate),
13851291
OPT_CALLBACK_F(0, "empty", &options, "{drop,keep,ask}",
13861292
N_("how to handle commits that become empty"),
@@ -1448,8 +1354,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
14481354
strbuf_reset(&buf);
14491355
strbuf_addf(&buf, "%s/rewritten", merge_dir());
14501356
if (is_directory(buf.buf)) {
1451-
options.type = REBASE_PRESERVE_MERGES;
1452-
options.flags |= REBASE_INTERACTIVE_EXPLICIT;
1357+
die("`rebase -p` is no longer supported");
14531358
} else {
14541359
strbuf_reset(&buf);
14551360
strbuf_addf(&buf, "%s/interactive", merge_dir());
@@ -1470,6 +1375,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
14701375
builtin_rebase_options,
14711376
builtin_rebase_usage, 0);
14721377

1378+
if (preserve_merges_selected)
1379+
die(_("--preserve-merges was replaced by --rebase-merges"));
1380+
14731381
if (action != ACTION_NONE && total_argc != 2) {
14741382
usage_with_options(builtin_rebase_usage,
14751383
builtin_rebase_options);
@@ -1479,10 +1387,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
14791387
usage_with_options(builtin_rebase_usage,
14801388
builtin_rebase_options);
14811389

1482-
if (options.type == REBASE_PRESERVE_MERGES)
1483-
warning(_("git rebase --preserve-merges is deprecated. "
1484-
"Use --rebase-merges instead."));
1485-
14861390
if (keep_base) {
14871391
if (options.onto_name)
14881392
die(_("cannot combine '--keep-base' with '--onto'"));
@@ -1728,7 +1632,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
17281632
case REBASE_APPLY:
17291633
die(_("--strategy requires --merge or --interactive"));
17301634
case REBASE_MERGE:
1731-
case REBASE_PRESERVE_MERGES:
17321635
/* compatible */
17331636
break;
17341637
case REBASE_UNSPECIFIED:
@@ -1780,7 +1683,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
17801683

17811684
switch (options.type) {
17821685
case REBASE_MERGE:
1783-
case REBASE_PRESERVE_MERGES:
17841686
options.state_dir = merge_dir();
17851687
break;
17861688
case REBASE_APPLY:
@@ -1805,28 +1707,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
18051707
options.reschedule_failed_exec = reschedule_failed_exec;
18061708

18071709
if (options.signoff) {
1808-
if (options.type == REBASE_PRESERVE_MERGES)
1809-
die("cannot combine '--signoff' with "
1810-
"'--preserve-merges'");
18111710
strvec_push(&options.git_am_opts, "--signoff");
18121711
options.flags |= REBASE_FORCE;
18131712
}
18141713

1815-
if (options.type == REBASE_PRESERVE_MERGES) {
1816-
/*
1817-
* Note: incompatibility with --signoff handled in signoff block above
1818-
* Note: incompatibility with --interactive is just a strong warning;
1819-
* git-rebase.txt caveats with "unless you know what you are doing"
1820-
*/
1821-
if (options.rebase_merges)
1822-
die(_("cannot combine '--preserve-merges' with "
1823-
"'--rebase-merges'"));
1824-
1825-
if (options.reschedule_failed_exec)
1826-
die(_("error: cannot combine '--preserve-merges' with "
1827-
"'--reschedule-failed-exec'"));
1828-
}
1829-
18301714
if (!options.root) {
18311715
if (argc < 1) {
18321716
struct branch *branch;

0 commit comments

Comments
 (0)