summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile1
-rw-r--r--builtin.h1
-rw-r--r--builtin/rebase--helper.c40
-rw-r--r--git.c1
5 files changed, 44 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index b1020b875f..833ef3b0b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -114,6 +114,7 @@
/git-read-tree
/git-rebase
/git-rebase--am
+/git-rebase--helper
/git-rebase--interactive
/git-rebase--merge
/git-receive-pack
diff --git a/Makefile b/Makefile
index 8e4081e061..29f8663509 100644
--- a/Makefile
+++ b/Makefile
@@ -932,6 +932,7 @@ BUILTIN_OBJS += builtin/prune.o
BUILTIN_OBJS += builtin/pull.o
BUILTIN_OBJS += builtin/push.o
BUILTIN_OBJS += builtin/read-tree.o
+BUILTIN_OBJS += builtin/rebase--helper.o
BUILTIN_OBJS += builtin/receive-pack.o
BUILTIN_OBJS += builtin/reflog.o
BUILTIN_OBJS += builtin/remote.o
diff --git a/builtin.h b/builtin.h
index 67f80519da..9e4a89816d 100644
--- a/builtin.h
+++ b/builtin.h
@@ -103,6 +103,7 @@ extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
extern int cmd_pull(int argc, const char **argv, const char *prefix);
extern int cmd_push(int argc, const char **argv, const char *prefix);
extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_rebase__helper(int argc, const char **argv, const char *prefix);
extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);
extern int cmd_reflog(int argc, const char **argv, const char *prefix);
extern int cmd_remote(int argc, const char **argv, const char *prefix);
diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c
new file mode 100644
index 0000000000..ca1ebb2fa1
--- /dev/null
+++ b/builtin/rebase--helper.c
@@ -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);
+}
diff --git a/git.c b/git.c
index c887272b12..33f52acbcc 100644
--- a/git.c
+++ b/git.c
@@ -473,6 +473,7 @@ static struct cmd_struct commands[] = {
{ "pull", cmd_pull, RUN_SETUP | NEED_WORK_TREE },
{ "push", cmd_push, RUN_SETUP },
{ "read-tree", cmd_read_tree, RUN_SETUP | SUPPORT_SUPER_PREFIX},
+ { "rebase--helper", cmd_rebase__helper, RUN_SETUP | NEED_WORK_TREE },
{ "receive-pack", cmd_receive_pack },
{ "reflog", cmd_reflog, RUN_SETUP },
{ "remote", cmd_remote, RUN_SETUP },