sequencer: make three functions and an enum from sequencer.c public

This makes rebase_path_todo(), get_missing_commit_check_level(), write_message() and the enum check_level accessible outside sequencer.c, renames check_level to missing_commit_check_level, and prefixes its value names by MISSING_COMMIT_ to avoid namespace pollution. This function and this enum will eventually be moved to rebase-interactive.c and become static again, so no special attention was given to the naming. This will be needed for the rewrite of append_todo_help() from shell to C, as it will be in a new library source file, rebase-interactive.c. Signed-off-by: Alban Gruin <alban.gruin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alban Gruin committed Aug 10, 2018 at 18:51 UTC 44b776c3e9bcbfcb7fbf78baafc67394cf56e812
2 files changed +22 -15
sequencer.c
+11 -15
@@ -52,7 +52,7 @@ static GIT_PATH_FUNC(rebase_path, "rebase-merge")
52 * the lines are processed, they are removed from the front of this
53 * file and written to the tail of 'done'.
54 */
55 -static GIT_PATH_FUNC(rebase_path_todo, "rebase-merge/git-rebase-todo")
55 +GIT_PATH_FUNC(rebase_path_todo, "rebase-merge/git-rebase-todo")
56 /*
57 * The rebase command lines that have already been processed. A line
58 * is moved here when it is first handled, before any associated user
@@ -373,8 +373,8 @@ static void print_advice(int show_hint, struct replay_opts *opts)
373 }
374 }
375
376 -static int write_message(const void *buf, size_t len, const char *filename,
377 - int append_eol)
376 +int write_message(const void *buf, size_t len, const char *filename,
377 + int append_eol)
378 {
379 struct lock_file msg_file = LOCK_INIT;
380
@@ -4245,24 +4245,20 @@ int transform_todos(unsigned flags)
4245 return i;
4246 }
4247
4248 -enum check_level {
4249 - CHECK_IGNORE = 0, CHECK_WARN, CHECK_ERROR
4250 -};
4251 -
4252 -static enum check_level get_missing_commit_check_level(void)
4248 +enum missing_commit_check_level get_missing_commit_check_level(void)
4249 {
4250 const char *value;
4251
4252 if (git_config_get_value("rebase.missingcommitscheck", &value) ||
4253 !strcasecmp("ignore", value))
4258 - return CHECK_IGNORE;
4254 + return MISSING_COMMIT_CHECK_IGNORE;
4255 if (!strcasecmp("warn", value))
4260 - return CHECK_WARN;
4256 + return MISSING_COMMIT_CHECK_WARN;
4257 if (!strcasecmp("error", value))
4262 - return CHECK_ERROR;
4258 + return MISSING_COMMIT_CHECK_ERROR;
4259 warning(_("unrecognized setting %s for option "
4260 "rebase.missingCommitsCheck. Ignoring."), value);
4265 - return CHECK_IGNORE;
4261 + return MISSING_COMMIT_CHECK_IGNORE;
4262 }
4263
4264 define_commit_slab(commit_seen, unsigned char);
@@ -4274,7 +4270,7 @@ define_commit_slab(commit_seen, unsigned char);
4270 */
4271 int check_todo_list(void)
4272 {
4277 - enum check_level check_level = get_missing_commit_check_level();
4273 + enum missing_commit_check_level check_level = get_missing_commit_check_level();
4274 struct strbuf todo_file = STRBUF_INIT;
4275 struct todo_list todo_list = TODO_LIST_INIT;
4276 struct strbuf missing = STRBUF_INIT;
@@ -4291,7 +4287,7 @@ int check_todo_list(void)
4287 advise_to_edit_todo = res =
4288 parse_insn_buffer(todo_list.buf.buf, &todo_list);
4289
4294 - if (res || check_level == CHECK_IGNORE)
4290 + if (res || check_level == MISSING_COMMIT_CHECK_IGNORE)
4291 goto leave_check;
4292
4293 /* Mark the commits in git-rebase-todo as seen */
@@ -4326,7 +4322,7 @@ int check_todo_list(void)
4322 if (!missing.len)
4323 goto leave_check;
4324
4329 - if (check_level == CHECK_ERROR)
4325 + if (check_level == MISSING_COMMIT_CHECK_ERROR)
4326 advise_to_edit_todo = res = 1;
4327
4328 fprintf(stderr,
sequencer.h
+11
@@ -3,6 +3,7 @@
3
4 const char *git_path_commit_editmsg(void);
5 const char *git_path_seq_dir(void);
6 +const char *rebase_path_todo(void);
7
8 #define APPEND_SIGNOFF_DEDUP (1u << 0)
9
@@ -57,6 +58,15 @@ struct replay_opts {
58 };
59 #define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT }
60
61 +enum missing_commit_check_level {
62 + MISSING_COMMIT_CHECK_IGNORE = 0,
63 + MISSING_COMMIT_CHECK_WARN,
64 + MISSING_COMMIT_CHECK_ERROR
65 +};
66 +
67 +int write_message(const void *buf, size_t len, const char *filename,
68 + int append_eol);
69 +
70 /* Call this to setup defaults before parsing command line options */
71 void sequencer_init_config(struct replay_opts *opts);
72 int sequencer_pick_revisions(struct replay_opts *opts);
@@ -79,6 +89,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
89
90 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(void);
95 int rearrange_squash(void);