Skip to content

Commit 150946b

Browse files
gitsterdscho
authored andcommitted
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=interactive Forward-port from upstream Git. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents e6c1b67 + 17c4ddb commit 150946b

File tree

6 files changed

+32
-7
lines changed

6 files changed

+32
-7
lines changed

Documentation/config.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,8 @@ When preserve, also pass `--preserve-merges` along to 'git rebase'
891891
so that locally committed merge commits will not be flattened
892892
by running 'git pull'.
893893
+
894+
When the value is `interactive`, the rebase is run in interactive mode.
895+
+
894896
*NOTE*: this is a possibly dangerous operation; do *not* use
895897
it unless you understand the implications (see linkgit:git-rebase[1]
896898
for details).
@@ -2170,6 +2172,8 @@ When preserve, also pass `--preserve-merges` along to 'git rebase'
21702172
so that locally committed merge commits will not be flattened
21712173
by running 'git pull'.
21722174
+
2175+
When the value is `interactive`, the rebase is run in interactive mode.
2176+
+
21732177
*NOTE*: this is a possibly dangerous operation; do *not* use
21742178
it unless you understand the implications (see linkgit:git-rebase[1]
21752179
for details).

Documentation/git-pull.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Options related to merging
101101
include::merge-options.txt[]
102102

103103
-r::
104-
--rebase[=false|true|preserve]::
104+
--rebase[=false|true|preserve|interactive]::
105105
When true, rebase the current branch on top of the upstream
106106
branch after fetching. If there is a remote-tracking branch
107107
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.
113113
+
114114
When false, merge the current branch into the upstream branch.
115115
+
116+
When `interactive`, enable the interactive mode of rebase.
117+
+
116118
See `pull.rebase`, `branch.<name>.rebase` and `branch.autoSetupRebase` in
117119
linkgit:git-config[1] if you want to make `git pull` always use
118120
`--rebase` instead of merging.

builtin/pull.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ enum rebase_type {
2222
REBASE_INVALID = -1,
2323
REBASE_FALSE = 0,
2424
REBASE_TRUE,
25-
REBASE_PRESERVE
25+
REBASE_PRESERVE,
26+
REBASE_INTERACTIVE
2627
};
2728

2829
/**
@@ -42,6 +43,8 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value,
4243
return REBASE_TRUE;
4344
else if (!strcmp(value, "preserve"))
4445
return REBASE_PRESERVE;
46+
else if (!strcmp(value, "interactive"))
47+
return REBASE_INTERACTIVE;
4548

4649
if (fatal)
4750
die(_("Invalid value for %s: %s"), key, value);
@@ -112,7 +115,7 @@ static struct option pull_options[] = {
112115
/* Options passed to git-merge or git-rebase */
113116
OPT_GROUP(N_("Options related to merging")),
114117
{ OPTION_CALLBACK, 'r', "rebase", &opt_rebase,
115-
"false|true|preserve",
118+
"false|true|preserve|interactive",
116119
N_("incorporate changes by rebasing rather than merging"),
117120
PARSE_OPT_OPTARG, parse_opt_rebase },
118121
OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL,
@@ -772,6 +775,8 @@ static int run_rebase(const unsigned char *curr_head,
772775
/* Options passed to git-rebase */
773776
if (opt_rebase == REBASE_PRESERVE)
774777
argv_array_push(&args, "--preserve-merges");
778+
else if (opt_rebase == REBASE_INTERACTIVE)
779+
argv_array_push(&args, "--interactive");
775780
if (opt_diffstat)
776781
argv_array_push(&args, opt_diffstat);
777782
argv_array_pushv(&args, opt_strategies.argv);

builtin/remote.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static int add(int argc, const char **argv)
251251
struct branch_info {
252252
char *remote_name;
253253
struct string_list merge;
254-
int rebase;
254+
enum { NO_REBASE, NORMAL_REBASE, INTERACTIVE_REBASE } rebase;
255255
};
256256

257257
static struct string_list branch_list;
@@ -311,7 +311,9 @@ static int config_read_branches(const char *key, const char *value, void *cb)
311311
if (v >= 0)
312312
info->rebase = v;
313313
else if (!strcmp(value, "preserve"))
314-
info->rebase = 1;
314+
info->rebase = NORMAL_REBASE;
315+
else if (!strcmp(value, "interactive"))
316+
info->rebase = INTERACTIVE_REBASE;
315317
}
316318
}
317319
return 0;
@@ -980,7 +982,9 @@ static int show_local_info_item(struct string_list_item *item, void *cb_data)
980982

981983
printf(" %-*s ", show_info->width, item->string);
982984
if (branch_info->rebase) {
983-
printf_ln(_("rebases onto remote %s"), merge->items[0].string);
985+
printf_ln(_(branch_info->rebase == INTERACTIVE_REBASE ?
986+
"rebases interactively onto remote %s" :
987+
"rebases onto remote %s"), merge->items[0].string);
984988
return 0;
985989
} else if (show_info->any_rebase) {
986990
printf_ln(_(" merges with remote %s"), merge->items[0].string);

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ _git_config ()
18081808
return
18091809
;;
18101810
branch.*.rebase)
1811-
__gitcomp "false true"
1811+
__gitcomp "false true preserve interactive"
18121812
return
18131813
;;
18141814
remote.pushdefault)

t/t5520-pull.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,16 @@ test_expect_success 'pull.rebase=preserve rebases and merges keep-merge' '
326326
test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
327327
'
328328

329+
test_expect_success 'pull.rebase=interactive' '
330+
write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF &&
331+
echo I was here >fake.out &&
332+
false
333+
EOF
334+
test_set_editor "$TRASH_DIRECTORY/fake-editor" &&
335+
test_must_fail git pull --rebase=interactive . copy &&
336+
test "I was here" = "$(cat fake.out)"
337+
'
338+
329339
test_expect_success 'pull.rebase=invalid fails' '
330340
git reset --hard before-preserve-rebase &&
331341
test_config pull.rebase invalid &&

0 commit comments

Comments
 (0)