@@ -60,6 +60,7 @@ enum empty_type {
60
60
struct rebase_options {
61
61
enum rebase_type type ;
62
62
enum empty_type empty ;
63
+ const char * default_backend ;
63
64
const char * state_dir ;
64
65
struct commit * upstream ;
65
66
const char * upstream_name ;
@@ -100,6 +101,7 @@ struct rebase_options {
100
101
#define REBASE_OPTIONS_INIT { \
101
102
.type = REBASE_UNSPECIFIED, \
102
103
.empty = EMPTY_UNSPECIFIED, \
104
+ .default_backend = "am", \
103
105
.flags = REBASE_NO_QUIET, \
104
106
.git_am_opts = ARGV_ARRAY_INIT, \
105
107
.git_format_patch_opt = STRBUF_INIT \
@@ -1272,6 +1274,10 @@ static int rebase_config(const char *var, const char *value, void *data)
1272
1274
return 0 ;
1273
1275
}
1274
1276
1277
+ if (!strcmp (var , "rebase.backend" )) {
1278
+ return git_config_string (& opts -> default_backend , var , value );
1279
+ }
1280
+
1275
1281
return git_default_config (var , value , data );
1276
1282
}
1277
1283
@@ -1900,9 +1906,23 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1900
1906
if (strcmp (options .git_am_opts .argv [i ], "-q" ))
1901
1907
break ;
1902
1908
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 );
1906
1926
}
1907
1927
1908
1928
switch (options .type ) {
@@ -1915,10 +1935,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1915
1935
options .state_dir = apply_dir ();
1916
1936
break ;
1917
1937
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." );
1922
1939
}
1923
1940
1924
1941
if (options .empty == EMPTY_UNSPECIFIED ) {
0 commit comments