git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[GSoC][PATCH v5 1/2] sequencer: make two functions and an enum from sequencer.c public

From
Alban Gruin <alban.gruin@gmail.com>
Date
Jun 28, 2018, 10:04 UTC
Message-ID
<20180628100411.8092-2-alban.gruin@gmail.com>
In-Reply-To
<20180628100411.8092-1-alban.gruin@gmail.com>

This makes rebase_path_todo(), get_missing_commit_check_level() and the enum check_level accessible outside sequencer.c. check_level is renamed missing_commit_check_level, and its value names are prefixed by MISSING_COMMIT_ to avoid namespace pollution.

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>
---
 sequencer.c | 22 +++++++++-------------
 sequencer.h |  8 ++++++++
 2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 0a291c91f..cb7ec9807 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -52,7 +52,7 @@ static GIT_PATH_FUNC(rebase_path, "rebase-merge")
  * the lines are processed, they are removed from the front of this
  * file and written to the tail of 'done'.
  */
-static GIT_PATH_FUNC(rebase_path_todo, "rebase-merge/git-rebase-todo")
+GIT_PATH_FUNC(rebase_path_todo, "rebase-merge/git-rebase-todo")
 /*
  * The rebase command lines that have already been processed. A line
  * is moved here when it is first handled, before any associated user
@@ -4223,24 +4223,20 @@ int transform_todos(unsigned flags)
 	return i;
 }
 
-enum check_level {
-	CHECK_IGNORE = 0, CHECK_WARN, CHECK_ERROR
-};
-
-static enum check_level get_missing_commit_check_level(void)
+enum missing_commit_check_level get_missing_commit_check_level(void)
 {
 	const char *value;
 
 	if (git_config_get_value("rebase.missingcommitscheck", &value) ||
 			!strcasecmp("ignore", value))
-		return CHECK_IGNORE;
+		return MISSING_COMMIT_CHECK_IGNORE;
 	if (!strcasecmp("warn", value))
-		return CHECK_WARN;
+		return MISSING_COMMIT_CHECK_WARN;
 	if (!strcasecmp("error", value))
-		return CHECK_ERROR;
+		return MISSING_COMMIT_CHECK_ERROR;
 	warning(_("unrecognized setting %s for option "
 		  "rebase.missingCommitsCheck. Ignoring."), value);
-	return CHECK_IGNORE;
+	return MISSING_COMMIT_CHECK_IGNORE;
 }
 
 define_commit_slab(commit_seen, unsigned char);
@@ -4252,7 +4248,7 @@ define_commit_slab(commit_seen, unsigned char);
  */
 int check_todo_list(void)
 {
-	enum check_level check_level = get_missing_commit_check_level();
+	enum missing_commit_check_level check_level = get_missing_commit_check_level();
 	struct strbuf todo_file = STRBUF_INIT;
 	struct todo_list todo_list = TODO_LIST_INIT;
 	struct strbuf missing = STRBUF_INIT;
@@ -4269,7 +4265,7 @@ int check_todo_list(void)
 	advise_to_edit_todo = res =
 		parse_insn_buffer(todo_list.buf.buf, &todo_list);
 
-	if (res || check_level == CHECK_IGNORE)
+	if (res || check_level == MISSING_COMMIT_CHECK_IGNORE)
 		goto leave_check;
 
 	/* Mark the commits in git-rebase-todo as seen */
@@ -4304,7 +4300,7 @@ int check_todo_list(void)
 	if (!missing.len)
 		goto leave_check;
 
-	if (check_level == CHECK_ERROR)
+	if (check_level == MISSING_COMMIT_CHECK_ERROR)
 		advise_to_edit_todo = res = 1;
 
 	fprintf(stderr,
diff --git a/sequencer.h b/sequencer.h
index c5787c6b5..ffab798f1 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -3,6 +3,7 @@
 
 const char *git_path_commit_editmsg(void);
 const char *git_path_seq_dir(void);
+const char *rebase_path_todo(void);
 
 #define APPEND_SIGNOFF_DEDUP (1u << 0)
 
@@ -57,6 +58,12 @@ struct replay_opts {
 };
 #define REPLAY_OPTS_INIT { .action = -1, .current_fixups = STRBUF_INIT }
 
+enum missing_commit_check_level {
+	MISSING_COMMIT_CHECK_IGNORE = 0,
+	MISSING_COMMIT_CHECK_WARN,
+	MISSING_COMMIT_CHECK_ERROR
+};
+
 /* Call this to setup defaults before parsing command line options */
 void sequencer_init_config(struct replay_opts *opts);
 int sequencer_pick_revisions(struct replay_opts *opts);
@@ -79,6 +86,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
 
 int sequencer_add_exec_commands(const char *command);
 int transform_todos(unsigned flags);
+enum missing_commit_check_level get_missing_commit_check_level(void);
 int check_todo_list(void);
 int skip_unnecessary_picks(void);
 int rearrange_squash(void);
-- 
2.18.0
Previous: Alban GruinNext: Alban Gruin
Message 25 of 27 in “rebase -i: rewrite append_todo_help() in C”
  1. Alban GruinMay 31, 2018
  2. [GSoC][PATCH 1/2] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, May 31, 2018
  3. [GSoC][PATCH 2/2] sequencer: remove newlines from append_todo_help() messagesAlban Gruin, May 31, 2018
  4. Phillip WoodMay 31, 2018
  5. Stefan BellerMay 31, 2018
  6. Alban GruinMay 31, 2018
  7. Stefan BellerMay 31, 2018
  8. Phillip WoodJun 1, 2018
  9. Stefan BellerJun 1, 2018
  10. Alban GruinMay 31, 2018
  11. Phillip WoodJun 1, 2018
  12. [GSoC][PATCH v2 0/1] rebase -i: rewrite append_todo_help() in CAlban Gruin, Jun 5, 2018
  13. [GSoC][PATCH v2 1/1] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, Jun 5, 2018
  14. [GSoC][PATCH v3 0/1] rebase -i: rewrite append_todo_help() in CAlban Gruin, Jun 7, 2018
  15. [GSoC][PATCH v3 1/1] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, Jun 7, 2018
  16. [GSoC][PATCH v4 0/2] rebase -i: rewrite append_todo_help() in CAlban Gruin, Jun 26, 2018
  17. [GSoC][PATCH v4 1/2] sequencer: make two functions and an enum from sequencer.c publicAlban Gruin, Jun 26, 2018
  18. Johannes SchindelinJun 26, 2018
  19. Alban GruinJun 27, 2018
  20. [GSoC][PATCH v4 2/2] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, Jun 26, 2018
  21. Johannes SchindelinJun 26, 2018
  22. Johannes SchindelinJun 26, 2018
  23. Alban GruinJun 27, 2018
  24. [GSoC][PATCH v5 0/2] rebase -i: rewrite append_todo_help() in CAlban Gruin, Jun 28, 2018
  25. [GSoC][PATCH v5 1/2] sequencer: make two functions and an enum from sequencer.c publicAlban Gruin, Jun 28, 2018
  26. [GSoC][PATCH v5 2/2] rebase--interactive: rewrite append_todo_help() in CAlban Gruin, Jun 28, 2018
  27. Junio C HamanoJun 28, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.