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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-09 23:23:06 +01:00
|
|
|
#include "builtin.h"
|
|
|
|
#include "cache.h"
|
2017-06-14 20:07:36 +02:00
|
|
|
#include "config.h"
|
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-09 23:23:06 +01:00
|
|
|
#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;
|
2017-07-14 16:44:58 +02:00
|
|
|
int keep_empty = 0;
|
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-09 23:23:06 +01:00
|
|
|
enum {
|
2017-07-14 16:45:21 +02:00
|
|
|
CONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_SHA1S, EXPAND_SHA1S,
|
2017-07-14 16:45:31 +02:00
|
|
|
CHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH
|
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-09 23:23:06 +01:00
|
|
|
} command = 0;
|
|
|
|
struct option options[] = {
|
|
|
|
OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
|
2017-07-14 16:44:58 +02:00
|
|
|
OPT_BOOL(0, "keep-empty", &keep_empty, N_("keep empty commits")),
|
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-09 23:23:06 +01:00
|
|
|
OPT_CMDMODE(0, "continue", &command, N_("continue rebase"),
|
|
|
|
CONTINUE),
|
|
|
|
OPT_CMDMODE(0, "abort", &command, N_("abort rebase"),
|
|
|
|
ABORT),
|
2017-07-14 16:44:58 +02:00
|
|
|
OPT_CMDMODE(0, "make-script", &command,
|
|
|
|
N_("make rebase script"), MAKE_SCRIPT),
|
2017-07-14 16:45:11 +02:00
|
|
|
OPT_CMDMODE(0, "shorten-ids", &command,
|
|
|
|
N_("shorten SHA-1s in the todo list"), SHORTEN_SHA1S),
|
|
|
|
OPT_CMDMODE(0, "expand-ids", &command,
|
|
|
|
N_("expand SHA-1s in the todo list"), EXPAND_SHA1S),
|
2017-07-14 16:45:21 +02:00
|
|
|
OPT_CMDMODE(0, "check-todo-list", &command,
|
|
|
|
N_("check the todo list"), CHECK_TODO_LIST),
|
2017-07-14 16:45:25 +02:00
|
|
|
OPT_CMDMODE(0, "skip-unnecessary-picks", &command,
|
|
|
|
N_("skip unnecessary picks"), SKIP_UNNECESSARY_PICKS),
|
2017-07-14 16:45:31 +02:00
|
|
|
OPT_CMDMODE(0, "rearrange-squash", &command,
|
|
|
|
N_("rearrange fixup/squash lines"), REARRANGE_SQUASH),
|
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-09 23:23:06 +01:00
|
|
|
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);
|
2017-07-14 16:44:58 +02:00
|
|
|
if (command == MAKE_SCRIPT && argc > 1)
|
|
|
|
return !!sequencer_make_script(keep_empty, stdout, argc, argv);
|
2017-07-14 16:45:11 +02:00
|
|
|
if (command == SHORTEN_SHA1S && argc == 1)
|
|
|
|
return !!transform_todo_ids(1);
|
|
|
|
if (command == EXPAND_SHA1S && argc == 1)
|
|
|
|
return !!transform_todo_ids(0);
|
2017-07-14 16:45:21 +02:00
|
|
|
if (command == CHECK_TODO_LIST && argc == 1)
|
|
|
|
return !!check_todo_list();
|
2017-07-14 16:45:25 +02:00
|
|
|
if (command == SKIP_UNNECESSARY_PICKS && argc == 1)
|
|
|
|
return !!skip_unnecessary_picks();
|
2017-07-14 16:45:31 +02:00
|
|
|
if (command == REARRANGE_SQUASH && argc == 1)
|
|
|
|
return !!rearrange_squash();
|
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-02-09 23:23:06 +01:00
|
|
|
usage_with_options(builtin_rebase_helper_usage, options);
|
|
|
|
}
|