Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-02-16 00:36:39 +0300
committerJunio C Hamano <gitster@pobox.com>2020-02-17 02:40:42 +0300
commit8295ed690bf1d458f80cffdc17d663eb3ba5162a (patch)
tree5ea6c29352d37379d8a287a65c7fce79493473b0 /builtin/rebase.c
parent76340c8107ba8e658f9cc76d1d220bac2944d1f1 (diff)
rebase: make the backend configurable via config setting
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r--builtin/rebase.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index ffaa7935240..f0a862f41b5 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -60,6 +60,7 @@ enum empty_type {
struct rebase_options {
enum rebase_type type;
enum empty_type empty;
+ const char *default_backend;
const char *state_dir;
struct commit *upstream;
const char *upstream_name;
@@ -100,6 +101,7 @@ struct rebase_options {
#define REBASE_OPTIONS_INIT { \
.type = REBASE_UNSPECIFIED, \
.empty = EMPTY_UNSPECIFIED, \
+ .default_backend = "am", \
.flags = REBASE_NO_QUIET, \
.git_am_opts = ARGV_ARRAY_INIT, \
.git_format_patch_opt = STRBUF_INIT \
@@ -1272,6 +1274,10 @@ static int rebase_config(const char *var, const char *value, void *data)
return 0;
}
+ if (!strcmp(var, "rebase.backend")) {
+ return git_config_string(&opts->default_backend, var, value);
+ }
+
return git_default_config(var, value, data);
}
@@ -1900,9 +1906,23 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
if (strcmp(options.git_am_opts.argv[i], "-q"))
break;
- if (is_interactive(&options) && i >= 0)
- die(_("cannot combine am options with either "
- "interactive or merge options"));
+ if (i >= 0) {
+ if (is_interactive(&options))
+ die(_("cannot combine am options with either "
+ "interactive or merge options"));
+ else
+ options.type = REBASE_AM;
+ }
+ }
+
+ if (options.type == REBASE_UNSPECIFIED) {
+ if (!strcmp(options.default_backend, "merge"))
+ options.type = REBASE_MERGE;
+ else if (!strcmp(options.default_backend, "am"))
+ options.type = REBASE_AM;
+ else
+ die(_("Unknown rebase backend: %s"),
+ options.default_backend);
}
switch (options.type) {
@@ -1915,10 +1935,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
options.state_dir = apply_dir();
break;
default:
- /* the default rebase backend is `--am` */
- options.type = REBASE_AM;
- options.state_dir = apply_dir();
- break;
+ BUG("options.type was just set above; should be unreachable.");
}
if (options.empty == EMPTY_UNSPECIFIED) {