Skip to content

Commit 03e6e8e

Browse files
agrngitster
authored andcommitted
rebase -i: move rebase--helper modes to rebase--interactive
This moves the rebase--helper modes still used by git-rebase--preserve-merges.sh (`--shorten-ids`, `--expand-ids`, `--check-todo-list`, `--rearrange-squash` and `--add-exec-commands`) to rebase--interactive.c. git-rebase--preserve-merges.sh is modified accordingly, and rebase--helper.c is removed as it is useless now. Signed-off-by: Alban Gruin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 046adc2 commit 03e6e8e

7 files changed

+31
-236
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
/git-read-tree
117117
/git-rebase
118118
/git-rebase--am
119-
/git-rebase--helper
120119
/git-rebase--interactive
121120
/git-rebase--merge
122121
/git-rebase--preserve-merges

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,6 @@ BUILTIN_OBJS += builtin/prune.o
10591059
BUILTIN_OBJS += builtin/pull.o
10601060
BUILTIN_OBJS += builtin/push.o
10611061
BUILTIN_OBJS += builtin/read-tree.o
1062-
BUILTIN_OBJS += builtin/rebase--helper.o
10631062
BUILTIN_OBJS += builtin/rebase--interactive.o
10641063
BUILTIN_OBJS += builtin/receive-pack.o
10651064
BUILTIN_OBJS += builtin/reflog.o

builtin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ extern int cmd_pull(int argc, const char **argv, const char *prefix);
203203
extern int cmd_push(int argc, const char **argv, const char *prefix);
204204
extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
205205
extern int cmd_rebase__interactive(int argc, const char **argv, const char *prefix);
206-
extern int cmd_rebase__helper(int argc, const char **argv, const char *prefix);
207206
extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);
208207
extern int cmd_reflog(int argc, const char **argv, const char *prefix);
209208
extern int cmd_remote(int argc, const char **argv, const char *prefix);

builtin/rebase--helper.c

Lines changed: 0 additions & 226 deletions
This file was deleted.

builtin/rebase--interactive.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
140140
*switch_to = NULL, *cmd = NULL;
141141
char *raw_strategies = NULL;
142142
enum {
143-
NONE = 0, CONTINUE, SKIP, EDIT_TODO, SHOW_CURRENT_PATCH
143+
NONE = 0, CONTINUE, SKIP, EDIT_TODO, SHOW_CURRENT_PATCH,
144+
SHORTEN_OIDS, EXPAND_OIDS, CHECK_TODO_LIST, REARRANGE_SQUASH, ADD_EXEC
144145
} command = 0;
145146
struct option options[] = {
146147
OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
@@ -161,6 +162,16 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
161162
EDIT_TODO),
162163
OPT_CMDMODE(0, "show-current-patch", &command, N_("show the current patch"),
163164
SHOW_CURRENT_PATCH),
165+
OPT_CMDMODE(0, "shorten-ids", &command,
166+
N_("shorten commit ids in the todo list"), SHORTEN_OIDS),
167+
OPT_CMDMODE(0, "expand-ids", &command,
168+
N_("expand commit ids in the todo list"), EXPAND_OIDS),
169+
OPT_CMDMODE(0, "check-todo-list", &command,
170+
N_("check the todo list"), CHECK_TODO_LIST),
171+
OPT_CMDMODE(0, "rearrange-squash", &command,
172+
N_("rearrange fixup/squash lines"), REARRANGE_SQUASH),
173+
OPT_CMDMODE(0, "add-exec-commands", &command,
174+
N_("insert exec commands in todo list"), ADD_EXEC),
164175
OPT_STRING(0, "onto", &onto, N_("onto"), N_("onto")),
165176
OPT_STRING(0, "restrict-revision", &restrict_revision,
166177
N_("restrict-revision"), N_("restrict revision")),
@@ -199,6 +210,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
199210
flags |= abbreviate_commands ? TODO_LIST_ABBREVIATE_CMDS : 0;
200211
flags |= rebase_merges ? TODO_LIST_REBASE_MERGES : 0;
201212
flags |= rebase_cousins > 0 ? TODO_LIST_REBASE_COUSINS : 0;
213+
flags |= command == SHORTEN_OIDS ? TODO_LIST_SHORTEN_IDS : 0;
202214

203215
if (rebase_cousins >= 0 && !rebase_merges)
204216
warning(_("--[no-]rebase-cousins has no effect without "
@@ -231,6 +243,19 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
231243

232244
break;
233245
}
246+
case SHORTEN_OIDS:
247+
case EXPAND_OIDS:
248+
ret = transform_todos(flags);
249+
break;
250+
case CHECK_TODO_LIST:
251+
ret = check_todo_list();
252+
break;
253+
case REARRANGE_SQUASH:
254+
ret = rearrange_squash();
255+
break;
256+
case ADD_EXEC:
257+
ret = sequencer_add_exec_commands(cmd);
258+
break;
234259
default:
235260
BUG("invalid command '%d'", command);
236261
}

git-rebase--preserve-merges.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,11 @@ do_rest () {
711711
}
712712

713713
expand_todo_ids() {
714-
git rebase--helper --expand-ids
714+
git rebase--interactive --expand-ids
715715
}
716716

717717
collapse_todo_ids() {
718-
git rebase--helper --shorten-ids
718+
git rebase--interactive --shorten-ids
719719
}
720720

721721
# Switch to the branch in $into and notify it in the reflog
@@ -876,8 +876,8 @@ init_revisions_and_shortrevisions () {
876876

877877
complete_action() {
878878
test -s "$todo" || echo noop >> "$todo"
879-
test -z "$autosquash" || git rebase--helper --rearrange-squash || exit
880-
test -n "$cmd" && git rebase--helper --add-exec-commands "$cmd"
879+
test -z "$autosquash" || git rebase--interactive --rearrange-squash || exit
880+
test -n "$cmd" && git rebase--interactive --add-exec-commands --cmd "$cmd"
881881

882882
todocount=$(git stripspace --strip-comments <"$todo" | wc -l)
883883
todocount=${todocount##* }
@@ -912,7 +912,7 @@ EOF
912912
has_action "$todo" ||
913913
return 2
914914

915-
git rebase--helper --check-todo-list || {
915+
git rebase--interactive --check-todo-list || {
916916
ret=$?
917917
checkout_onto
918918
exit $ret

git.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,6 @@ static struct cmd_struct commands[] = {
519519
{ "push", cmd_push, RUN_SETUP },
520520
{ "read-tree", cmd_read_tree, RUN_SETUP | SUPPORT_SUPER_PREFIX},
521521
{ "rebase--interactive", cmd_rebase__interactive, RUN_SETUP | NEED_WORK_TREE },
522-
{ "rebase--helper", cmd_rebase__helper, RUN_SETUP | NEED_WORK_TREE },
523522
{ "receive-pack", cmd_receive_pack },
524523
{ "reflog", cmd_reflog, RUN_SETUP },
525524
{ "remote", cmd_remote, RUN_SETUP },

0 commit comments

Comments
 (0)