summaryrefslogtreecommitdiff
path: root/builtin/rebase--helper.c
diff options
context:
space:
mode:
authorAlban Gruin <alban.gruin@gmail.com>2018-08-28 12:10:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-29 20:38:18 (GMT)
commit65850686cf072d6de88880247adb7113db8a52f2 (patch)
tree5fbea0be6ec16fe712d62503ed6a885b804bc9c8 /builtin/rebase--helper.c
parentf22e4e1a3c2faaac59099aaca15641c18f478f77 (diff)
downloadgit-65850686cf072d6de88880247adb7113db8a52f2.zip
git-65850686cf072d6de88880247adb7113db8a52f2.tar.gz
git-65850686cf072d6de88880247adb7113db8a52f2.tar.bz2
rebase -i: rewrite write_basic_state() in C
This rewrites write_basic_state() from git-rebase.sh in C. This is the first step in the conversion of init_basic_state(), hence the mode in rebase--helper.c is called INIT_BASIC_STATE. init_basic_state() will be converted in the next commit. The part of read_strategy_opts() that parses the stategy options is moved to a new function to allow its use in rebase--helper.c. Finally, the call to write_basic_state() is removed from git-rebase--interactive.sh, replaced by a call to `--init-basic-state`. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase--helper.c')
-rw-r--r--builtin/rebase--helper.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c
index 0716bbf..63c5086 100644
--- a/builtin/rebase--helper.c
+++ b/builtin/rebase--helper.c
@@ -5,6 +5,8 @@
#include "sequencer.h"
#include "rebase-interactive.h"
#include "argv-array.h"
+#include "rerere.h"
+#include "alias.h"
static GIT_PATH_FUNC(path_squash_onto, "rebase-merge/squash-onto")
@@ -53,11 +55,12 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
unsigned flags = 0, keep_empty = 0, rebase_merges = 0, autosquash = 0;
int abbreviate_commands = 0, rebase_cousins = -1, ret;
const char *head_hash = NULL, *onto = NULL, *restrict_revision = NULL,
- *squash_onto = NULL, *upstream = NULL;
+ *squash_onto = NULL, *upstream = NULL, *head_name = NULL;
+ char *raw_strategies = NULL;
enum {
CONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_OIDS, EXPAND_OIDS,
CHECK_TODO_LIST, REARRANGE_SQUASH, ADD_EXEC, EDIT_TODO, PREPARE_BRANCH,
- COMPLETE_ACTION
+ COMPLETE_ACTION, INIT_BASIC_STATE
} command = 0;
struct option options[] = {
OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
@@ -69,6 +72,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
N_("keep original branch points of cousins")),
OPT_BOOL(0, "autosquash", &autosquash,
N_("move commits that begin with squash!/fixup!")),
+ OPT_BOOL(0, "signoff", &opts.signoff, N_("sign commits")),
OPT__VERBOSE(&opts.verbose, N_("be verbose")),
OPT_CMDMODE(0, "continue", &command, N_("continue rebase"),
CONTINUE),
@@ -93,6 +97,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
N_("prepare the branch to be rebased"), PREPARE_BRANCH),
OPT_CMDMODE(0, "complete-action", &command,
N_("complete the action"), COMPLETE_ACTION),
+ OPT_CMDMODE(0, "init-basic-state", &command,
+ N_("initialise the rebase state"), INIT_BASIC_STATE),
OPT_STRING(0, "onto", &onto, N_("onto"), N_("onto")),
OPT_STRING(0, "restrict-revision", &restrict_revision,
N_("restrict-revision"), N_("restrict revision")),
@@ -100,6 +106,14 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
N_("squash onto")),
OPT_STRING(0, "upstream", &upstream, N_("upstream"),
N_("the upstream commit")),
+ OPT_STRING(0, "head-name", &head_name, N_("head-name"), N_("head name")),
+ OPT_STRING('S', "gpg-sign", &opts.gpg_sign, N_("gpg-sign"),
+ N_("GPG-sign commits")),
+ OPT_STRING(0, "strategy", &opts.strategy, N_("strategy"),
+ N_("rebase strategy")),
+ OPT_STRING(0, "strategy-opts", &raw_strategies, N_("strategy-opts"),
+ N_("strategy options")),
+ OPT_RERERE_AUTOUPDATE(&opts.allow_rerere_auto),
OPT_END()
};
@@ -176,6 +190,16 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
free(shortrevisions);
return !!ret;
}
+ if (command == INIT_BASIC_STATE) {
+ if (raw_strategies)
+ parse_strategy_opts(&opts, raw_strategies);
+
+ ret = get_revision_ranges(upstream, onto, &head_hash, NULL, NULL);
+ if (ret)
+ return ret;
+
+ return !!write_basic_state(&opts, head_name, onto, head_hash);
+ }
usage_with_options(builtin_rebase_helper_usage, options);
}