@@ -60,6 +60,7 @@ enum empty_type {
6060struct rebase_options {
6161 enum rebase_type type ;
6262 enum empty_type empty ;
63+ const char * default_backend ;
6364 const char * state_dir ;
6465 struct commit * upstream ;
6566 const char * upstream_name ;
@@ -100,6 +101,7 @@ struct rebase_options {
100101#define REBASE_OPTIONS_INIT { \
101102 .type = REBASE_UNSPECIFIED, \
102103 .empty = EMPTY_UNSPECIFIED, \
104+ .default_backend = "am", \
103105 .flags = REBASE_NO_QUIET, \
104106 .git_am_opts = ARGV_ARRAY_INIT, \
105107 .git_format_patch_opt = STRBUF_INIT \
@@ -1272,6 +1274,10 @@ static int rebase_config(const char *var, const char *value, void *data)
12721274 return 0 ;
12731275 }
12741276
1277+ if (!strcmp (var , "rebase.backend" )) {
1278+ return git_config_string (& opts -> default_backend , var , value );
1279+ }
1280+
12751281 return git_default_config (var , value , data );
12761282}
12771283
@@ -1900,9 +1906,23 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
19001906 if (strcmp (options .git_am_opts .argv [i ], "-q" ))
19011907 break ;
19021908
1903- if (is_interactive (& options ) && i >= 0 )
1904- die (_ ("cannot combine am options with either "
1905- "interactive or merge options" ));
1909+ if (i >= 0 ) {
1910+ if (is_interactive (& options ))
1911+ die (_ ("cannot combine am options with either "
1912+ "interactive or merge options" ));
1913+ else
1914+ options .type = REBASE_AM ;
1915+ }
1916+ }
1917+
1918+ if (options .type == REBASE_UNSPECIFIED ) {
1919+ if (!strcmp (options .default_backend , "merge" ))
1920+ options .type = REBASE_MERGE ;
1921+ else if (!strcmp (options .default_backend , "am" ))
1922+ options .type = REBASE_AM ;
1923+ else
1924+ die (_ ("Unknown rebase backend: %s" ),
1925+ options .default_backend );
19061926 }
19071927
19081928 switch (options .type ) {
@@ -1915,10 +1935,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
19151935 options .state_dir = apply_dir ();
19161936 break ;
19171937 default :
1918- /* the default rebase backend is `--am` */
1919- options .type = REBASE_AM ;
1920- options .state_dir = apply_dir ();
1921- break ;
1938+ BUG ("options.type was just set above; should be unreachable." );
19221939 }
19231940
19241941 if (options .empty == EMPTY_UNSPECIFIED ) {
0 commit comments