Skip to content

Commit 1644c73

Browse files
dschogitster
authored andcommitted
rebase-helper --make-script: introduce a flag to rebase merges
The sequencer just learned new commands intended to recreate branch structure (similar in spirit to --preserve-merges, but with a substantially less-broken design). Let's allow the rebase--helper to generate todo lists making use of these commands, triggered by the new --rebase-merges option. For a commit topology like this (where the HEAD points to C): - A - B - C \ / D the generated todo list would look like this: # branch D pick 0123 A label branch-point pick 1234 D label D reset branch-point pick 2345 B merge -C 3456 D # C To keep things simple, we first only implement support for merge commits with exactly two parents, leaving support for octopus merges to a later patch series. All merge-rebasing todo lists start with a hard-coded `label onto` line. This makes it convenient to refer later on to the revision onto which everything is rebased, e.g. as starting point for branches other than the very first one. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d1e8b01 commit 1644c73

File tree

3 files changed

+349
-2
lines changed

3 files changed

+349
-2
lines changed

builtin/rebase--helper.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static const char * const builtin_rebase_helper_usage[] = {
1212
int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
1313
{
1414
struct replay_opts opts = REPLAY_OPTS_INIT;
15-
unsigned flags = 0, keep_empty = 0;
15+
unsigned flags = 0, keep_empty = 0, rebase_merges = 0;
1616
int abbreviate_commands = 0;
1717
enum {
1818
CONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_OIDS, EXPAND_OIDS,
@@ -24,6 +24,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
2424
OPT_BOOL(0, "keep-empty", &keep_empty, N_("keep empty commits")),
2525
OPT_BOOL(0, "allow-empty-message", &opts.allow_empty_message,
2626
N_("allow commits with empty messages")),
27+
OPT_BOOL(0, "rebase-merges", &rebase_merges, N_("rebase merge commits")),
2728
OPT_CMDMODE(0, "continue", &command, N_("continue rebase"),
2829
CONTINUE),
2930
OPT_CMDMODE(0, "abort", &command, N_("abort rebase"),
@@ -57,6 +58,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
5758

5859
flags |= keep_empty ? TODO_LIST_KEEP_EMPTY : 0;
5960
flags |= abbreviate_commands ? TODO_LIST_ABBREVIATE_CMDS : 0;
61+
flags |= rebase_merges ? TODO_LIST_REBASE_MERGES : 0;
6062
flags |= command == SHORTEN_OIDS ? TODO_LIST_SHORTEN_IDS : 0;
6163

6264
if (command == CONTINUE && argc == 1)

0 commit comments

Comments
 (0)