-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rebase--helper: add a builtin helper for interactive rebases
Git"s interactive rebase is still implemented as a shell script, despite its complexity. This implies that it suffers from the portability point of view, from lack of expressibility, and of course also from performance. The latter issue is particularly serious on Windows, where we pay a hefty price for relying so much on POSIX. Unfortunately, being such a huge shell script also means that we missed the train when it would have been relatively easy to port it to C, and instead piled feature upon feature onto that poor script that originally never intended to be more than a slightly pimped cherry-pick in a loop. To open the road toward better performance (in addition to all the other benefits of C over shell scripts), let"s just start *somewhere*. The approach taken here is to add a builtin helper that at first intends to take care of the parts of the interactive rebase that are most affected by the performance penalties mentioned above. In particular, after we spent all those efforts on preparing the sequencer to process rebase -i"s git-rebase-todo scripts, we implement the `git rebase -i --continue` functionality as a new builtin, git-rebase--helper. Once that is in place, we can work gradually on tackling the rest of the technical debt. Note that the rebase--helper needs to learn about the transient --ff/--no-ff options of git-rebase, as the corresponding flag is not persisted to, and re-read from, the state directory. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
- Loading branch information
Showing
5 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "builtin.h" | ||
#include "cache.h" | ||
#include "parse-options.h" | ||
#include "sequencer.h" | ||
|
||
static const char * const builtin_rebase_helper_usage[] = { | ||
N_("git rebase--helper [<options>]"), | ||
NULL | ||
}; | ||
|
||
int cmd_rebase__helper(int argc, const char **argv, const char *prefix) | ||
{ | ||
struct replay_opts opts = REPLAY_OPTS_INIT; | ||
enum { | ||
CONTINUE = 1, ABORT | ||
} command = 0; | ||
struct option options[] = { | ||
OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")), | ||
OPT_CMDMODE(0, "continue", &command, N_("continue rebase"), | ||
CONTINUE), | ||
OPT_CMDMODE(0, "abort", &command, N_("abort rebase"), | ||
ABORT), | ||
OPT_END() | ||
}; | ||
|
||
git_config(git_default_config, NULL); | ||
|
||
opts.action = REPLAY_INTERACTIVE_REBASE; | ||
opts.allow_ff = 1; | ||
opts.allow_empty = 1; | ||
|
||
argc = parse_options(argc, argv, NULL, options, | ||
builtin_rebase_helper_usage, PARSE_OPT_KEEP_ARGV0); | ||
|
||
if (command == CONTINUE && argc == 1) | ||
return !!sequencer_continue(&opts); | ||
if (command == ABORT && argc == 1) | ||
return !!sequencer_remove_state(&opts); | ||
usage_with_options(builtin_rebase_helper_usage, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters