@@ -48,8 +48,7 @@ static GIT_PATH_FUNC(merge_dir, "rebase-merge")
48
48
enum rebase_type {
49
49
REBASE_UNSPECIFIED = -1 ,
50
50
REBASE_APPLY ,
51
- REBASE_MERGE ,
52
- REBASE_PRESERVE_MERGES
51
+ REBASE_MERGE
53
52
};
54
53
55
54
enum empty_type {
@@ -571,8 +570,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
571
570
572
571
static int is_merge (struct rebase_options * opts )
573
572
{
574
- return opts -> type == REBASE_MERGE ||
575
- opts -> type == REBASE_PRESERVE_MERGES ;
573
+ return opts -> type == REBASE_MERGE ;
576
574
}
577
575
578
576
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)
582
580
die (_ ("%s requires the merge backend" ), option );
583
581
break ;
584
582
case REBASE_MERGE :
585
- case REBASE_PRESERVE_MERGES :
586
583
break ;
587
584
default :
588
585
opts -> type = REBASE_MERGE ; /* implied */
@@ -773,17 +770,6 @@ static struct commit *peel_committish(const char *name)
773
770
return (struct commit * )peel_to_type (name , 0 , obj , OBJ_COMMIT );
774
771
}
775
772
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
-
787
773
static int move_to_original_branch (struct rebase_options * opts )
788
774
{
789
775
struct strbuf orig_head_reflog = STRBUF_INIT , head_reflog = STRBUF_INIT ;
@@ -940,10 +926,7 @@ static int run_am(struct rebase_options *opts)
940
926
941
927
static int run_specific_rebase (struct rebase_options * opts , enum action action )
942
928
{
943
- const char * argv [] = { NULL , NULL };
944
- struct strbuf script_snippet = STRBUF_INIT , buf = STRBUF_INIT ;
945
929
int status ;
946
- const char * backend , * backend_func ;
947
930
948
931
if (opts -> type == REBASE_MERGE ) {
949
932
/* Run sequencer-based rebase */
@@ -960,87 +943,11 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
960
943
}
961
944
962
945
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 )
967
947
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
1034
949
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 ;
1041
950
1042
- status = run_command_v_opt (argv , RUN_USING_SHELL );
1043
- finished_rebase :
1044
951
if (opts -> dont_finish_rebase )
1045
952
; /* do nothing */
1046
953
else if (opts -> type == REBASE_MERGE )
@@ -1058,8 +965,6 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action)
1058
965
die ("Nothing to do" );
1059
966
}
1060
967
1061
- strbuf_release (& script_snippet );
1062
-
1063
968
return status ? -1 : 0 ;
1064
969
}
1065
970
@@ -1313,6 +1218,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1313
1218
char * squash_onto_name = NULL ;
1314
1219
int reschedule_failed_exec = -1 ;
1315
1220
int allow_preemptive_ff = 1 ;
1221
+ int preserve_merges_selected = 0 ;
1316
1222
struct option builtin_rebase_options [] = {
1317
1223
OPT_STRING (0 , "onto" , & options .onto_name ,
1318
1224
N_ ("revision" ),
@@ -1377,10 +1283,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1377
1283
N_ ("let the user edit the list of commits to rebase" ),
1378
1284
PARSE_OPT_NOARG | PARSE_OPT_NONEG ,
1379
1285
parse_opt_interactive ),
1380
- OPT_SET_INT_F ('p' , "preserve-merges" , & options . type ,
1286
+ OPT_SET_INT_F ('p' , "preserve-merges" , & preserve_merges_selected ,
1381
1287
N_ ("(DEPRECATED) try to recreate merges instead of "
1382
1288
"ignoring them" ),
1383
- REBASE_PRESERVE_MERGES , PARSE_OPT_HIDDEN ),
1289
+ 1 , PARSE_OPT_HIDDEN ),
1384
1290
OPT_RERERE_AUTOUPDATE (& options .allow_rerere_autoupdate ),
1385
1291
OPT_CALLBACK_F (0 , "empty" , & options , "{drop,keep,ask}" ,
1386
1292
N_ ("how to handle commits that become empty" ),
@@ -1448,8 +1354,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1448
1354
strbuf_reset (& buf );
1449
1355
strbuf_addf (& buf , "%s/rewritten" , merge_dir ());
1450
1356
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" );
1453
1358
} else {
1454
1359
strbuf_reset (& buf );
1455
1360
strbuf_addf (& buf , "%s/interactive" , merge_dir ());
@@ -1470,6 +1375,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1470
1375
builtin_rebase_options ,
1471
1376
builtin_rebase_usage , 0 );
1472
1377
1378
+ if (preserve_merges_selected )
1379
+ die (_ ("--preserve-merges was replaced by --rebase-merges" ));
1380
+
1473
1381
if (action != ACTION_NONE && total_argc != 2 ) {
1474
1382
usage_with_options (builtin_rebase_usage ,
1475
1383
builtin_rebase_options );
@@ -1479,10 +1387,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1479
1387
usage_with_options (builtin_rebase_usage ,
1480
1388
builtin_rebase_options );
1481
1389
1482
- if (options .type == REBASE_PRESERVE_MERGES )
1483
- warning (_ ("git rebase --preserve-merges is deprecated. "
1484
- "Use --rebase-merges instead." ));
1485
-
1486
1390
if (keep_base ) {
1487
1391
if (options .onto_name )
1488
1392
die (_ ("cannot combine '--keep-base' with '--onto'" ));
@@ -1728,7 +1632,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1728
1632
case REBASE_APPLY :
1729
1633
die (_ ("--strategy requires --merge or --interactive" ));
1730
1634
case REBASE_MERGE :
1731
- case REBASE_PRESERVE_MERGES :
1732
1635
/* compatible */
1733
1636
break ;
1734
1637
case REBASE_UNSPECIFIED :
@@ -1780,7 +1683,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1780
1683
1781
1684
switch (options .type ) {
1782
1685
case REBASE_MERGE :
1783
- case REBASE_PRESERVE_MERGES :
1784
1686
options .state_dir = merge_dir ();
1785
1687
break ;
1786
1688
case REBASE_APPLY :
@@ -1805,28 +1707,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1805
1707
options .reschedule_failed_exec = reschedule_failed_exec ;
1806
1708
1807
1709
if (options .signoff ) {
1808
- if (options .type == REBASE_PRESERVE_MERGES )
1809
- die ("cannot combine '--signoff' with "
1810
- "'--preserve-merges'" );
1811
1710
strvec_push (& options .git_am_opts , "--signoff" );
1812
1711
options .flags |= REBASE_FORCE ;
1813
1712
}
1814
1713
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
-
1830
1714
if (!options .root ) {
1831
1715
if (argc < 1 ) {
1832
1716
struct branch * branch ;
0 commit comments