Skip to content

Commit 88ba4bf

Browse files
committed
Merge branch 'js/rebase-i-final' into pu
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
2 parents 119a514 + 9733724 commit 88ba4bf

File tree

7 files changed

+625
-343
lines changed

7 files changed

+625
-343
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
@@ -11,15 +11,30 @@ static const char * const builtin_rebase_helper_usage[] = {
1111
int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
1212
{
1313
struct replay_opts opts = REPLAY_OPTS_INIT;
14+
int keep_empty = 0;
1415
enum {
15-
CONTINUE = 1, ABORT
16+
CONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_SHA1S, EXPAND_SHA1S,
17+
CHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH
1618
} command = 0;
1719
struct option options[] = {
1820
OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
21+
OPT_BOOL(0, "keep-empty", &keep_empty, N_("keep empty commits")),
1922
OPT_CMDMODE(0, "continue", &command, N_("continue rebase"),
2023
CONTINUE),
2124
OPT_CMDMODE(0, "abort", &command, N_("abort rebase"),
2225
ABORT),
26+
OPT_CMDMODE(0, "make-script", &command,
27+
N_("make rebase script"), MAKE_SCRIPT),
28+
OPT_CMDMODE(0, "shorten-sha1s", &command,
29+
N_("shorten SHA-1s in the todo list"), SHORTEN_SHA1S),
30+
OPT_CMDMODE(0, "expand-sha1s", &command,
31+
N_("expand SHA-1s in the todo list"), EXPAND_SHA1S),
32+
OPT_CMDMODE(0, "check-todo-list", &command,
33+
N_("check the todo list"), CHECK_TODO_LIST),
34+
OPT_CMDMODE(0, "skip-unnecessary-picks", &command,
35+
N_("skip unnecessary picks"), SKIP_UNNECESSARY_PICKS),
36+
OPT_CMDMODE(0, "rearrange-squash", &command,
37+
N_("rearrange fixup/squash lines"), REARRANGE_SQUASH),
2338
OPT_END()
2439
};
2540

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

0 commit comments

Comments
 (0)