Merge branch 'js/rebase-helper'

"git rebase -i" starts using the recently updated "sequencer" code.

* js/rebase-helper:
  rebase -i: use the rebase--helper builtin
  rebase--helper: add a builtin helper for interactive rebases
This commit is contained in:
Junio C Hamano 2017-02-27 13:57:14 -08:00
commit 098ed50e8a
7 changed files with 58 additions and 1 deletions

1
.gitignore vendored
View File

@ -114,6 +114,7 @@
/git-read-tree
/git-rebase
/git-rebase--am
/git-rebase--helper
/git-rebase--interactive
/git-rebase--merge
/git-receive-pack

View File

@ -933,6 +933,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

View File

@ -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);

40
builtin/rebase--helper.c Normal file
View File

@ -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);
}

View File

@ -1069,6 +1069,10 @@ git_rebase__interactive () {
case "$action" in
continue)
if test ! -d "$rewritten"
then
exec git rebase--helper ${force_rebase:+--no-ff} --continue
fi
# do we have anything to commit?
if git diff-index --cached --quiet HEAD --
then
@ -1128,6 +1132,10 @@ first and then run 'git rebase --continue' again.")"
skip)
git rerere clear
if test ! -d "$rewritten"
then
exec git rebase--helper ${force_rebase:+--no-ff} --continue
fi
do_rest
return 0
;;
@ -1314,6 +1322,11 @@ expand_todo_ids
test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
checkout_onto
if test -z "$rebase_root" && test ! -d "$rewritten"
then
require_clean_work_tree "rebase"
exec git rebase--helper ${force_rebase:+--no-ff} --continue
fi
do_rest
}

1
git.c
View File

@ -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 },

View File

@ -556,7 +556,7 @@ test_expect_success 'clean error after failed "exec"' '
echo "edited again" > file7 &&
git add file7 &&
test_must_fail git rebase --continue 2>error &&
test_i18ngrep "You have staged changes in your working tree." error
test_i18ngrep "you have staged changes in your working tree" error
'
test_expect_success 'rebase a detached HEAD' '