Re: [GSoC][PATCH v3 06/13] rebase -i: rewrite setup_reflog_action() in C
From: Junio C Hamano <hidden>
Date: 2018-07-10 18:20:17
Alban Gruin [off-list ref] writes:
quoted hunk
This rewrites (the misnamed) setup_reflog_action() from shell to C. The new version is called prepare_branch_to_be_rebased(). A new command is added to rebase--helper.c, “checkout-base”, as well as a new flag, “verbose”, to avoid silencing the output of the checkout operation called by checkout_base_commit(). The function `run_git_checkout()` will also be used in the next commit, therefore its code is not part of `checkout_base_commit()`. The shell version is then stripped in favour of a call to the helper. As $GIT_REFLOG_ACTION is no longer set at the first call of checkout_onto(), a call to comment_for_reflog() is added at the beginning of this function. Signed-off-by: Alban Gruin <redacted> --- builtin/rebase--helper.c | 10 ++++++++-- git-rebase--interactive.sh | 16 ++-------------- sequencer.c | 30 ++++++++++++++++++++++++++++++ sequencer.h | 2 ++ 4 files changed, 42 insertions(+), 16 deletions(-)diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c index 731a64971..76bdc6fdb 100644 --- a/builtin/rebase--helper.c +++ b/builtin/rebase--helper.c@@ -13,12 +13,12 @@ static const char * const builtin_rebase_helper_usage[] = { int cmd_rebase__helper(int argc, const char **argv, const char *prefix) { struct replay_opts opts = REPLAY_OPTS_INIT; - unsigned flags = 0, keep_empty = 0, rebase_merges = 0; + unsigned flags = 0, keep_empty = 0, rebase_merges = 0, verbose = 0;
...
quoted hunk
struct option options[] = { OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),@@ -28,6 +28,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix) OPT_BOOL(0, "rebase-merges", &rebase_merges, N_("rebase merge commits")), OPT_BOOL(0, "rebase-cousins", &rebase_cousins, N_("keep original branch points of cousins")), + OPT__VERBOSE(&verbose, N_("be verbose")),
...
quoted hunk
@@ -60,6 +63,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix) opts.action = REPLAY_INTERACTIVE_REBASE; opts.allow_ff = 1; opts.allow_empty = 1; + opts.verbose = verbose; argc = parse_options(argc, argv, NULL, options, builtin_rebase_helper_usage, PARSE_OPT_KEEP_ARGV0);@@ -94,5 +98,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix) return !!append_todo_help(0, keep_empty); if (command == EDIT_TODO && argc == 1) return !!edit_todo_list(flags); + if (command == PREPARE_BRANCH && argc == 2) + return !!prepare_branch_to_be_rebased(&opts, argv[1]);
Not passing verbose as a separate parameter, and using opts.verbose that already exists instead, is a sensible improvement from the previous round. I wonder if we need a new local variable, though? Just like &opts.allow_ff is used directly in options[] array, can't we give &opts.verbose to OPT__VERBOSE(), or would we break something if we did so?