@@ -48,8 +48,7 @@ static GIT_PATH_FUNC(merge_dir, "rebase-merge")
4848enum rebase_type {
4949 REBASE_UNSPECIFIED = -1 ,
5050 REBASE_APPLY ,
51- REBASE_MERGE ,
52- REBASE_PRESERVE_MERGES
51+ REBASE_MERGE
5352};
5453
5554enum empty_type {
@@ -571,8 +570,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
571570
572571static 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
578576static 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-
787773static 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
941927static 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