Skip to content

Commit 68cc555

Browse files
committed
Merge 'rebase--helper' into HEAD
2 parents b213911 + cdcb2b7 commit 68cc555

File tree

7 files changed

+58
-1
lines changed

7 files changed

+58
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
/git-read-tree
115115
/git-rebase
116116
/git-rebase--am
117+
/git-rebase--helper
117118
/git-rebase--interactive
118119
/git-rebase--merge
119120
/git-receive-pack

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ BUILTIN_OBJS += builtin/prune.o
930930
BUILTIN_OBJS += builtin/pull.o
931931
BUILTIN_OBJS += builtin/push.o
932932
BUILTIN_OBJS += builtin/read-tree.o
933+
BUILTIN_OBJS += builtin/rebase--helper.o
933934
BUILTIN_OBJS += builtin/receive-pack.o
934935
BUILTIN_OBJS += builtin/reflog.o
935936
BUILTIN_OBJS += builtin/remote.o

builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
103103
extern int cmd_pull(int argc, const char **argv, const char *prefix);
104104
extern int cmd_push(int argc, const char **argv, const char *prefix);
105105
extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
106+
extern int cmd_rebase__helper(int argc, const char **argv, const char *prefix);
106107
extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);
107108
extern int cmd_reflog(int argc, const char **argv, const char *prefix);
108109
extern int cmd_remote(int argc, const char **argv, const char *prefix);

builtin/rebase--helper.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include "builtin.h"
2+
#include "cache.h"
3+
#include "parse-options.h"
4+
#include "sequencer.h"
5+
6+
static const char * const builtin_rebase_helper_usage[] = {
7+
N_("git rebase--helper [<options>]"),
8+
NULL
9+
};
10+
11+
int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
12+
{
13+
struct replay_opts opts = REPLAY_OPTS_INIT;
14+
enum {
15+
CONTINUE = 1, ABORT
16+
} command = 0;
17+
struct option options[] = {
18+
OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
19+
OPT_CMDMODE(0, "continue", &command, N_("continue rebase"),
20+
CONTINUE),
21+
OPT_CMDMODE(0, "abort", &command, N_("abort rebase"),
22+
ABORT),
23+
OPT_END()
24+
};
25+
26+
git_config(git_default_config, NULL);
27+
28+
opts.action = REPLAY_INTERACTIVE_REBASE;
29+
opts.allow_ff = 1;
30+
opts.allow_empty = 1;
31+
32+
argc = parse_options(argc, argv, NULL, options,
33+
builtin_rebase_helper_usage, PARSE_OPT_KEEP_ARGV0);
34+
35+
if (command == CONTINUE && argc == 1)
36+
return !!sequencer_continue(&opts);
37+
if (command == ABORT && argc == 1)
38+
return !!sequencer_remove_state(&opts);
39+
usage_with_options(builtin_rebase_helper_usage, options);
40+
}

git-rebase--interactive.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,10 @@ git_rebase__interactive () {
10691069

10701070
case "$action" in
10711071
continue)
1072+
if test ! -d "$rewritten"
1073+
then
1074+
exec git rebase--helper ${force_rebase:+--no-ff} --continue
1075+
fi
10721076
# do we have anything to commit?
10731077
if git diff-index --cached --quiet HEAD --
10741078
then
@@ -1128,6 +1132,10 @@ first and then run 'git rebase --continue' again.")"
11281132
skip)
11291133
git rerere clear
11301134

1135+
if test ! -d "$rewritten"
1136+
then
1137+
exec git rebase--helper ${force_rebase:+--no-ff} --continue
1138+
fi
11311139
do_rest
11321140
return 0
11331141
;;
@@ -1314,6 +1322,11 @@ expand_todo_ids
13141322
test -d "$rewritten" || test -n "$force_rebase" || skip_unnecessary_picks
13151323

13161324
checkout_onto
1325+
if test -z "$rebase_root" && test ! -d "$rewritten"
1326+
then
1327+
require_clean_work_tree "rebase"
1328+
exec git rebase--helper ${force_rebase:+--no-ff} --continue
1329+
fi
13171330
do_rest
13181331

13191332
}

git.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ static struct cmd_struct commands[] = {
473473
{ "pull", cmd_pull, RUN_SETUP | NEED_WORK_TREE },
474474
{ "push", cmd_push, RUN_SETUP },
475475
{ "read-tree", cmd_read_tree, RUN_SETUP | SUPPORT_SUPER_PREFIX},
476+
{ "rebase--helper", cmd_rebase__helper, RUN_SETUP | NEED_WORK_TREE },
476477
{ "receive-pack", cmd_receive_pack },
477478
{ "reflog", cmd_reflog, RUN_SETUP },
478479
{ "remote", cmd_remote, RUN_SETUP },

t/t3404-rebase-interactive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ test_expect_success 'clean error after failed "exec"' '
556556
echo "edited again" > file7 &&
557557
git add file7 &&
558558
test_must_fail git rebase --continue 2>error &&
559-
test_i18ngrep "You have staged changes in your working tree." error
559+
test_i18ngrep "you have staged changes in your working tree" error
560560
'
561561

562562
test_expect_success 'rebase a detached HEAD' '

0 commit comments

Comments
 (0)