Skip to content

Commit 44b776c

Browse files
agrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b7bd948 commit 44b776c

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

sequencer.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static GIT_PATH_FUNC(rebase_path, "rebase-merge")
5252
* the lines are processed, they are removed from the front of this
5353
* file and written to the tail of 'done'.
5454
*/
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")
5656
/*
5757
* The rebase command lines that have already been processed. A line
5858
* 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)
373373
}
374374
}
375375

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)
378378
{
379379
struct lock_file msg_file = LOCK_INIT;
380380

@@ -4245,24 +4245,20 @@ int transform_todos(unsigned flags)
42454245
return i;
42464246
}
42474247

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)
42534249
{
42544250
const char *value;
42554251

42564252
if (git_config_get_value("rebase.missingcommitscheck", &value) ||
42574253
!strcasecmp("ignore", value))
4258-
return CHECK_IGNORE;
4254+
return MISSING_COMMIT_CHECK_IGNORE;
42594255
if (!strcasecmp("warn", value))
4260-
return CHECK_WARN;
4256+
return MISSING_COMMIT_CHECK_WARN;
42614257
if (!strcasecmp("error", value))
4262-
return CHECK_ERROR;
4258+
return MISSING_COMMIT_CHECK_ERROR;
42634259
warning(_("unrecognized setting %s for option "
42644260
"rebase.missingCommitsCheck. Ignoring."), value);
4265-
return CHECK_IGNORE;
4261+
return MISSING_COMMIT_CHECK_IGNORE;
42664262
}
42674263

42684264
define_commit_slab(commit_seen, unsigned char);
@@ -4274,7 +4270,7 @@ define_commit_slab(commit_seen, unsigned char);
42744270
*/
42754271
int check_todo_list(void)
42764272
{
4277-
enum check_level check_level = get_missing_commit_check_level();
4273+
enum missing_commit_check_level check_level = get_missing_commit_check_level();
42784274
struct strbuf todo_file = STRBUF_INIT;
42794275
struct todo_list todo_list = TODO_LIST_INIT;
42804276
struct strbuf missing = STRBUF_INIT;
@@ -4291,7 +4287,7 @@ int check_todo_list(void)
42914287
advise_to_edit_todo = res =
42924288
parse_insn_buffer(todo_list.buf.buf, &todo_list);
42934289

4294-
if (res || check_level == CHECK_IGNORE)
4290+
if (res || check_level == MISSING_COMMIT_CHECK_IGNORE)
42954291
goto leave_check;
42964292

42974293
/* Mark the commits in git-rebase-todo as seen */
@@ -4326,7 +4322,7 @@ int check_todo_list(void)
43264322
if (!missing.len)
43274323
goto leave_check;
43284324

4329-
if (check_level == CHECK_ERROR)
4325+
if (check_level == MISSING_COMMIT_CHECK_ERROR)
43304326
advise_to_edit_todo = res = 1;
43314327

43324328
fprintf(stderr,

sequencer.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
const char *git_path_commit_editmsg(void);
55
const char *git_path_seq_dir(void);
6+
const char *rebase_path_todo(void);
67

78
#define APPEND_SIGNOFF_DEDUP (1u << 0)
89

@@ -57,6 +58,15 @@ struct replay_opts {
5758
};
5859
#define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT }
5960

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+
6070
/* Call this to setup defaults before parsing command line options */
6171
void sequencer_init_config(struct replay_opts *opts);
6272
int sequencer_pick_revisions(struct replay_opts *opts);
@@ -79,6 +89,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
7989

8090
int sequencer_add_exec_commands(const char *command);
8191
int transform_todos(unsigned flags);
92+
enum missing_commit_check_level get_missing_commit_check_level(void);
8293
int check_todo_list(void);
8394
int skip_unnecessary_picks(void);
8495
int rearrange_squash(void);

0 commit comments

Comments
 (0)