Merge branch 'js/pull-rebase-i'
"git pull --rebase" has been extended to allow invoking "rebase -i". * js/pull-rebase-i: completion: add missing branch.*.rebase values remote: handle the config setting branch.*.rebase=interactive pull: allow interactive rebase with --rebase=interactivemaint
commit
f9219c0b32
|
@ -870,6 +870,8 @@ When preserve, also pass `--preserve-merges` along to 'git rebase'
|
||||||
so that locally committed merge commits will not be flattened
|
so that locally committed merge commits will not be flattened
|
||||||
by running 'git pull'.
|
by running 'git pull'.
|
||||||
+
|
+
|
||||||
|
When the value is `interactive`, the rebase is run in interactive mode.
|
||||||
|
+
|
||||||
*NOTE*: this is a possibly dangerous operation; do *not* use
|
*NOTE*: this is a possibly dangerous operation; do *not* use
|
||||||
it unless you understand the implications (see linkgit:git-rebase[1]
|
it unless you understand the implications (see linkgit:git-rebase[1]
|
||||||
for details).
|
for details).
|
||||||
|
@ -2157,6 +2159,8 @@ When preserve, also pass `--preserve-merges` along to 'git rebase'
|
||||||
so that locally committed merge commits will not be flattened
|
so that locally committed merge commits will not be flattened
|
||||||
by running 'git pull'.
|
by running 'git pull'.
|
||||||
+
|
+
|
||||||
|
When the value is `interactive`, the rebase is run in interactive mode.
|
||||||
|
+
|
||||||
*NOTE*: this is a possibly dangerous operation; do *not* use
|
*NOTE*: this is a possibly dangerous operation; do *not* use
|
||||||
it unless you understand the implications (see linkgit:git-rebase[1]
|
it unless you understand the implications (see linkgit:git-rebase[1]
|
||||||
for details).
|
for details).
|
||||||
|
|
|
@ -101,7 +101,7 @@ Options related to merging
|
||||||
include::merge-options.txt[]
|
include::merge-options.txt[]
|
||||||
|
|
||||||
-r::
|
-r::
|
||||||
--rebase[=false|true|preserve]::
|
--rebase[=false|true|preserve|interactive]::
|
||||||
When true, rebase the current branch on top of the upstream
|
When true, rebase the current branch on top of the upstream
|
||||||
branch after fetching. If there is a remote-tracking branch
|
branch after fetching. If there is a remote-tracking branch
|
||||||
corresponding to the upstream branch and the upstream branch
|
corresponding to the upstream branch and the upstream branch
|
||||||
|
@ -113,6 +113,8 @@ to `git rebase` so that locally created merge commits will not be flattened.
|
||||||
+
|
+
|
||||||
When false, merge the current branch into the upstream branch.
|
When false, merge the current branch into the upstream branch.
|
||||||
+
|
+
|
||||||
|
When `interactive`, enable the interactive mode of rebase.
|
||||||
|
+
|
||||||
See `pull.rebase`, `branch.<name>.rebase` and `branch.autoSetupRebase` in
|
See `pull.rebase`, `branch.<name>.rebase` and `branch.autoSetupRebase` in
|
||||||
linkgit:git-config[1] if you want to make `git pull` always use
|
linkgit:git-config[1] if you want to make `git pull` always use
|
||||||
`--rebase` instead of merging.
|
`--rebase` instead of merging.
|
||||||
|
|
|
@ -22,7 +22,8 @@ enum rebase_type {
|
||||||
REBASE_INVALID = -1,
|
REBASE_INVALID = -1,
|
||||||
REBASE_FALSE = 0,
|
REBASE_FALSE = 0,
|
||||||
REBASE_TRUE,
|
REBASE_TRUE,
|
||||||
REBASE_PRESERVE
|
REBASE_PRESERVE,
|
||||||
|
REBASE_INTERACTIVE
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,6 +43,8 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
|
||||||
return REBASE_TRUE;
|
return REBASE_TRUE;
|
||||||
else if (!strcmp(value, "preserve"))
|
else if (!strcmp(value, "preserve"))
|
||||||
return REBASE_PRESERVE;
|
return REBASE_PRESERVE;
|
||||||
|
else if (!strcmp(value, "interactive"))
|
||||||
|
return REBASE_INTERACTIVE;
|
||||||
|
|
||||||
if (fatal)
|
if (fatal)
|
||||||
die(_("Invalid value for %s: %s"), key, value);
|
die(_("Invalid value for %s: %s"), key, value);
|
||||||
|
@ -113,7 +116,7 @@ static struct option pull_options[] = {
|
||||||
/* Options passed to git-merge or git-rebase */
|
/* Options passed to git-merge or git-rebase */
|
||||||
OPT_GROUP(N_("Options related to merging")),
|
OPT_GROUP(N_("Options related to merging")),
|
||||||
{ OPTION_CALLBACK, 'r', "rebase", &opt_rebase,
|
{ OPTION_CALLBACK, 'r', "rebase", &opt_rebase,
|
||||||
"false|true|preserve",
|
"false|true|preserve|interactive",
|
||||||
N_("incorporate changes by rebasing rather than merging"),
|
N_("incorporate changes by rebasing rather than merging"),
|
||||||
PARSE_OPT_OPTARG, parse_opt_rebase },
|
PARSE_OPT_OPTARG, parse_opt_rebase },
|
||||||
OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL,
|
OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL,
|
||||||
|
@ -778,6 +781,8 @@ static int run_rebase(const unsigned char *curr_head,
|
||||||
/* Options passed to git-rebase */
|
/* Options passed to git-rebase */
|
||||||
if (opt_rebase == REBASE_PRESERVE)
|
if (opt_rebase == REBASE_PRESERVE)
|
||||||
argv_array_push(&args, "--preserve-merges");
|
argv_array_push(&args, "--preserve-merges");
|
||||||
|
else if (opt_rebase == REBASE_INTERACTIVE)
|
||||||
|
argv_array_push(&args, "--interactive");
|
||||||
if (opt_diffstat)
|
if (opt_diffstat)
|
||||||
argv_array_push(&args, opt_diffstat);
|
argv_array_push(&args, opt_diffstat);
|
||||||
argv_array_pushv(&args, opt_strategies.argv);
|
argv_array_pushv(&args, opt_strategies.argv);
|
||||||
|
|
|
@ -251,7 +251,7 @@ static int add(int argc, const char **argv)
|
||||||
struct branch_info {
|
struct branch_info {
|
||||||
char *remote_name;
|
char *remote_name;
|
||||||
struct string_list merge;
|
struct string_list merge;
|
||||||
int rebase;
|
enum { NO_REBASE, NORMAL_REBASE, INTERACTIVE_REBASE } rebase;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct string_list branch_list;
|
static struct string_list branch_list;
|
||||||
|
@ -311,7 +311,9 @@ static int config_read_branches(const char *key, const char *value, void *cb)
|
||||||
if (v >= 0)
|
if (v >= 0)
|
||||||
info->rebase = v;
|
info->rebase = v;
|
||||||
else if (!strcmp(value, "preserve"))
|
else if (!strcmp(value, "preserve"))
|
||||||
info->rebase = 1;
|
info->rebase = NORMAL_REBASE;
|
||||||
|
else if (!strcmp(value, "interactive"))
|
||||||
|
info->rebase = INTERACTIVE_REBASE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -980,7 +982,9 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)
|
||||||
|
|
||||||
printf(" %-*s ", show_info->width, item->string);
|
printf(" %-*s ", show_info->width, item->string);
|
||||||
if (branch_info->rebase) {
|
if (branch_info->rebase) {
|
||||||
printf_ln(_("rebases onto remote %s"), merge->items[0].string);
|
printf_ln(_(branch_info->rebase == INTERACTIVE_REBASE ?
|
||||||
|
"rebases interactively onto remote %s" :
|
||||||
|
"rebases onto remote %s"), merge->items[0].string);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (show_info->any_rebase) {
|
} else if (show_info->any_rebase) {
|
||||||
printf_ln(_(" merges with remote %s"), merge->items[0].string);
|
printf_ln(_(" merges with remote %s"), merge->items[0].string);
|
||||||
|
|
|
@ -1809,7 +1809,7 @@ _git_config ()
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
branch.*.rebase)
|
branch.*.rebase)
|
||||||
__gitcomp "false true"
|
__gitcomp "false true preserve interactive"
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
remote.pushdefault)
|
remote.pushdefault)
|
||||||
|
|
|
@ -326,6 +326,16 @@ test_expect_success 'pull.rebase=preserve rebases and merges keep-merge' '
|
||||||
test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
|
test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'pull.rebase=interactive' '
|
||||||
|
write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF &&
|
||||||
|
echo I was here >fake.out &&
|
||||||
|
false
|
||||||
|
EOF
|
||||||
|
test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
|
||||||
|
test_must_fail git pull --rebase=interactive . copy &&
|
||||||
|
test "I was here" = "$(cat fake.out)"
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'pull.rebase=invalid fails' '
|
test_expect_success 'pull.rebase=invalid fails' '
|
||||||
git reset --hard before-preserve-rebase &&
|
git reset --hard before-preserve-rebase &&
|
||||||
test_config pull.rebase invalid &&
|
test_config pull.rebase invalid &&
|
||||||
|
|
Loading…
Reference in New Issue