Skip to content

Commit 5f3108b

Browse files
committed
Merge branch 'js/rebase-i-final'
The final batch to "git rebase -i" updates to move more code from the shell script to C. * js/rebase-i-final: rebase -i: rearrange fixup/squash lines using the rebase--helper t3415: test fixup with wrapped oneline rebase -i: skip unnecessary picks using the rebase--helper rebase -i: check for missing commits in the rebase--helper t3404: relax rebase.missingCommitsCheck tests rebase -i: also expand/collapse the SHA-1s via the rebase--helper rebase -i: do not invent onelines when expanding/collapsing SHA-1s rebase -i: remove useless indentation rebase -i: generate the script via rebase--helper t3415: verify that an empty instructionFormat is handled as before
2 parents ea220ee + c44a4c6 commit 5f3108b

File tree

7 files changed

+647
-360
lines changed

7 files changed

+647
-360
lines changed

Documentation/git-rebase.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,15 @@ without an explicit `--interactive`.
430430
--autosquash::
431431
--no-autosquash::
432432
When the commit log message begins with "squash! ..." (or
433-
"fixup! ..."), and there is a commit whose title begins with
434-
the same ..., automatically modify the todo list of rebase -i
435-
so that the commit marked for squashing comes right after the
436-
commit to be modified, and change the action of the moved
437-
commit from `pick` to `squash` (or `fixup`). Ignores subsequent
438-
"fixup! " or "squash! " after the first, in case you referred to an
439-
earlier fixup/squash with `git commit --fixup/--squash`.
433+
"fixup! ..."), and there is already a commit in the todo list that
434+
matches the same `...`, automatically modify the todo list of rebase
435+
-i so that the commit marked for squashing comes right after the
436+
commit to be modified, and change the action of the moved commit
437+
from `pick` to `squash` (or `fixup`). A commit matches the `...` if
438+
the commit subject matches, or if the `...` refers to the commit's
439+
hash. As a fall-back, partial matches of the commit subject work,
440+
too. The recommended way to create fixup/squash commits is by using
441+
the `--fixup`/`--squash` options of linkgit:git-commit[1].
440442
+
441443
This option is only valid when the `--interactive` option is used.
442444
+

builtin/rebase--helper.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,30 @@ 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+
int keep_empty = 0;
1516
enum {
16-
CONTINUE = 1, ABORT
17+
CONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_SHA1S, EXPAND_SHA1S,
18+
CHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH
1719
} command = 0;
1820
struct option options[] = {
1921
OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
22+
OPT_BOOL(0, "keep-empty", &keep_empty, N_("keep empty commits")),
2023
OPT_CMDMODE(0, "continue", &command, N_("continue rebase"),
2124
CONTINUE),
2225
OPT_CMDMODE(0, "abort", &command, N_("abort rebase"),
2326
ABORT),
27+
OPT_CMDMODE(0, "make-script", &command,
28+
N_("make rebase script"), MAKE_SCRIPT),
29+
OPT_CMDMODE(0, "shorten-ids", &command,
30+
N_("shorten SHA-1s in the todo list"), SHORTEN_SHA1S),
31+
OPT_CMDMODE(0, "expand-ids", &command,
32+
N_("expand SHA-1s in the todo list"), EXPAND_SHA1S),
33+
OPT_CMDMODE(0, "check-todo-list", &command,
34+
N_("check the todo list"), CHECK_TODO_LIST),
35+
OPT_CMDMODE(0, "skip-unnecessary-picks", &command,
36+
N_("skip unnecessary picks"), SKIP_UNNECESSARY_PICKS),
37+
OPT_CMDMODE(0, "rearrange-squash", &command,
38+
N_("rearrange fixup/squash lines"), REARRANGE_SQUASH),
2439
OPT_END()
2540
};
2641

@@ -37,5 +52,17 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
3752
return !!sequencer_continue(&opts);
3853
if (command == ABORT && argc == 1)
3954
return !!sequencer_remove_state(&opts);
55+
if (command == MAKE_SCRIPT && argc > 1)
56+
return !!sequencer_make_script(keep_empty, stdout, argc, argv);
57+
if (command == SHORTEN_SHA1S && argc == 1)
58+
return !!transform_todo_ids(1);
59+
if (command == EXPAND_SHA1S && argc == 1)
60+
return !!transform_todo_ids(0);
61+
if (command == CHECK_TODO_LIST && argc == 1)
62+
return !!check_todo_list();
63+
if (command == SKIP_UNNECESSARY_PICKS && argc == 1)
64+
return !!skip_unnecessary_picks();
65+
if (command == REARRANGE_SQUASH && argc == 1)
66+
return !!rearrange_squash();
4067
usage_with_options(builtin_rebase_helper_usage, options);
4168
}

0 commit comments

Comments
 (0)