rebase -i: remove unused modes and functions
This removes the modes `--skip-unnecessary-picks`, `--append-todo-help`, and `--checkout-onto` from rebase--helper.c, the functions of git-rebase--interactive.sh that were rendered useless by the rewrite of complete_action(), and append_todo_help_to_file() from rebase-interactive.c. skip_unnecessary_picks() and checkout_onto() becomes static, as they are only used inside of the sequencer. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alban Gruin committed
Aug 28, 2018 at 14:10 UTC
91f0d95dcb4dd9c388881b64a7d79a3809927126
6 files changed
+6
-102
builtin/rebase--helper.c
+2
-21
@@ -17,9 +17,8 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
17
int abbreviate_commands = 0, rebase_cousins = -1;
18
enum {
19
CONTINUE = 1, ABORT, MAKE_SCRIPT, SHORTEN_OIDS, EXPAND_OIDS,
20
- CHECK_TODO_LIST, SKIP_UNNECESSARY_PICKS, REARRANGE_SQUASH,
21
- ADD_EXEC, APPEND_TODO_HELP, EDIT_TODO, PREPARE_BRANCH,
22
- CHECKOUT_ONTO, COMPLETE_ACTION
20
+ CHECK_TODO_LIST, REARRANGE_SQUASH, ADD_EXEC, EDIT_TODO, PREPARE_BRANCH,
21
+ COMPLETE_ACTION
22
} command = 0;
23
struct option options[] = {
24
OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
@@ -44,21 +43,15 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
43
N_("expand commit ids in the todo list"), EXPAND_OIDS),
44
OPT_CMDMODE(0, "check-todo-list", &command,
45
N_("check the todo list"), CHECK_TODO_LIST),
47
- OPT_CMDMODE(0, "skip-unnecessary-picks", &command,
48
- N_("skip unnecessary picks"), SKIP_UNNECESSARY_PICKS),
46
OPT_CMDMODE(0, "rearrange-squash", &command,
47
N_("rearrange fixup/squash lines"), REARRANGE_SQUASH),
48
OPT_CMDMODE(0, "add-exec-commands", &command,
49
N_("insert exec commands in todo list"), ADD_EXEC),
53
- OPT_CMDMODE(0, "append-todo-help", &command,
54
- N_("insert the help in the todo list"), APPEND_TODO_HELP),
50
OPT_CMDMODE(0, "edit-todo", &command,
51
N_("edit the todo list during an interactive rebase"),
52
EDIT_TODO),
53
OPT_CMDMODE(0, "prepare-branch", &command,
54
N_("prepare the branch to be rebased"), PREPARE_BRANCH),
60
- OPT_CMDMODE(0, "checkout-onto", &command,
61
- N_("checkout a commit"), CHECKOUT_ONTO),
55
OPT_CMDMODE(0, "complete-action", &command,
56
N_("complete the action"), COMPLETE_ACTION),
57
OPT_END()
@@ -94,26 +87,14 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
87
return !!transform_todos(flags);
88
if (command == CHECK_TODO_LIST && argc == 1)
89
return !!check_todo_list();
97
- if (command == SKIP_UNNECESSARY_PICKS && argc == 1) {
98
- struct object_id oid;
99
- int ret = skip_unnecessary_picks(&oid);
100
-
101
- if (!ret)
102
- puts(oid_to_hex(&oid));
103
- return !!ret;
104
- }
90
if (command == REARRANGE_SQUASH && argc == 1)
91
return !!rearrange_squash();
92
if (command == ADD_EXEC && argc == 2)
93
return !!sequencer_add_exec_commands(argv[1]);
109
- if (command == APPEND_TODO_HELP && argc == 1)
110
- return !!append_todo_help_to_file(0, keep_empty);
94
if (command == EDIT_TODO && argc == 1)
95
return !!edit_todo_list(flags);
96
if (command == PREPARE_BRANCH && argc == 2)
97
return !!prepare_branch_to_be_rebased(&opts, argv[1]);
115
- if (command == CHECKOUT_ONTO && argc == 4)
116
- return !!checkout_onto(&opts, argv[1], argv[2], argv[3]);
98
if (command == COMPLETE_ACTION && argc == 6)
99
return !!complete_action(&opts, flags, argv[1], argv[2], argv[3],
100
argv[4], argv[5], autosquash);
git-rebase--interactive.sh
-50
@@ -16,56 +16,6 @@ todo="$state_dir"/git-rebase-todo
16
GIT_CHERRY_PICK_HELP="$resolvemsg"
17
export GIT_CHERRY_PICK_HELP
18
19
-comment_char=$(git config --get core.commentchar 2>/dev/null)
20
-case "$comment_char" in
21
-'' | auto)
22
- comment_char="#"
23
- ;;
24
-?)
25
- ;;
26
-*)
27
- comment_char=$(echo "$comment_char" | cut -c1)
28
- ;;
29
-esac
30
-
31
-die_abort () {
32
- apply_autostash
33
- rm -rf "$state_dir"
34
- die "$1"
35
-}
36
-
37
-has_action () {
38
- test -n "$(git stripspace --strip-comments <"$1")"
39
-}
40
-
41
-git_sequence_editor () {
42
- if test -z "$GIT_SEQUENCE_EDITOR"
43
- then
44
- GIT_SEQUENCE_EDITOR="$(git config sequence.editor)"
45
- if [ -z "$GIT_SEQUENCE_EDITOR" ]
46
- then
47
- GIT_SEQUENCE_EDITOR="$(git var GIT_EDITOR)" || return $?
48
- fi
49
- fi
50
-
51
- eval "$GIT_SEQUENCE_EDITOR" '"$@"'
52
-}
53
-
54
-expand_todo_ids() {
55
- git rebase--helper --expand-ids
56
-}
57
-
58
-collapse_todo_ids() {
59
- git rebase--helper --shorten-ids
60
-}
61
-
62
-get_missing_commit_check_level () {
63
- check_level=$(git config --get rebase.missingCommitsCheck)
64
- check_level=${check_level:-ignore}
65
- # Don't be case sensitive
66
- printf '%s' "$check_level" | tr 'A-Z' 'a-z'
67
-}
68
-
19
# Initiate an action. If the cannot be any
20
# further action it may exec a command
21
# or exit and not return.
rebase-interactive.c
-22
@@ -52,28 +52,6 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty,
52
}
53
}
54
55
-int append_todo_help_to_file(unsigned edit_todo, unsigned keep_empty)
56
-{
57
- struct strbuf buf = STRBUF_INIT;
58
- FILE *todo;
59
- int ret;
60
-
61
- todo = fopen_or_warn(rebase_path_todo(), "a");
62
- if (!todo)
63
- return -1;
64
-
65
- append_todo_help(edit_todo, keep_empty, &buf);
66
-
67
- ret = fputs(buf.buf, todo);
68
- if (ret < 0)
69
- error_errno(_("could not append help text to '%s'"), rebase_path_todo());
70
-
71
- fclose(todo);
72
- strbuf_release(&buf);
73
-
74
- return ret;
75
-}
76
-
55
int edit_todo_list(unsigned flags)
56
{
57
struct strbuf buf = STRBUF_INIT;
rebase-interactive.h
-1
@@ -3,7 +3,6 @@
3
4
void append_todo_help(unsigned edit_todo, unsigned keep_empty,
5
struct strbuf *buf);
6
-int append_todo_help_to_file(unsigned edit_todo, unsigned keep_empty);
6
int edit_todo_list(unsigned flags);
7
8
#endif
sequencer.c
+4
-4
@@ -3173,9 +3173,9 @@ int prepare_branch_to_be_rebased(struct replay_opts *opts, const char *commit)
3173
return 0;
3174
}
3175
3176
-int checkout_onto(struct replay_opts *opts,
3177
- const char *onto_name, const char *onto,
3178
- const char *orig_head)
3176
+static int checkout_onto(struct replay_opts *opts,
3177
+ const char *onto_name, const char *onto,
3178
+ const char *orig_head)
3179
{
3180
struct object_id oid;
3181
const char *action = reflog_message(opts, "start", "checkout %s", onto_name);
@@ -4420,7 +4420,7 @@ static int rewrite_file(const char *path, const char *buf, size_t len)
4420
}
4421
4422
/* skip picking commits whose parents are unchanged */
4423
-int skip_unnecessary_picks(struct object_id *output_oid)
4423
+static int skip_unnecessary_picks(struct object_id *output_oid)
4424
{
4425
const char *todo_file = rebase_path_todo();
4426
struct strbuf buf = STRBUF_INIT;
sequencer.h
-4
@@ -91,7 +91,6 @@ int sequencer_add_exec_commands(const char *command);
91
int transform_todos(unsigned flags);
92
enum missing_commit_check_level get_missing_commit_check_level(void);
93
int check_todo_list(void);
94
-int skip_unnecessary_picks(struct object_id *output_oid);
94
int complete_action(struct replay_opts *opts, unsigned flags,
95
const char *shortrevisions, const char *onto_name,
96
const char *onto, const char *orig_head, const char *cmd,
@@ -114,9 +113,6 @@ void commit_post_rewrite(const struct commit *current_head,
113
const struct object_id *new_head);
114
115
int prepare_branch_to_be_rebased(struct replay_opts *opts, const char *commit);
117
-int checkout_onto(struct replay_opts *opts,
118
- const char *onto_name, const char *onto,
119
- const char *orig_head);
116
117
#define SUMMARY_INITIAL_COMMIT (1 << 0)
118
#define SUMMARY_SHOW_AUTHOR_DATE (1 << 1)