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

[PATCH v3 2/5] sequencer.c: move static function to avoid forward decl

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 14, 2021, 00:15 UTC
Message-ID
<patch-2.5-9c1492b006-20210714T001433Z-avarab@gmail.com>
In-Reply-To
<cover-0.5-0000000000-20210714T001433Z-avarab@gmail.com>

Move the reflog_message() function added in 96e832a5fd6 (sequencer (rebase -i): refactor setting the reflog message, 2017-01-02), it gained another user in 9055e401dd6 (sequencer: introduce new commands to reset the revision, 2018-04-25). Let's move it around and remove the forward declaration added in the latter commit.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 sequencer.c | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 0bec01cf38..c316d8374a 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3599,7 +3599,25 @@ static int do_label(struct repository *r, const char *name, int len)
 }
 
 static const char *reflog_message(struct replay_opts *opts,
-	const char *sub_action, const char *fmt, ...);
+	const char *sub_action, const char *fmt, ...)
+{
+	va_list ap;
+	static struct strbuf buf = STRBUF_INIT;
+	char *reflog_action = getenv(GIT_REFLOG_ACTION);
+
+	va_start(ap, fmt);
+	strbuf_reset(&buf);
+	strbuf_addstr(&buf, reflog_action ? reflog_action : action_name(opts));
+	if (sub_action)
+		strbuf_addf(&buf, " (%s)", sub_action);
+	if (fmt) {
+		strbuf_addstr(&buf, ": ");
+		strbuf_vaddf(&buf, fmt, ap);
+	}
+	va_end(ap);
+
+	return buf.buf;
+}
 
 static int do_reset(struct repository *r,
 		    const char *name, int len,
@@ -4178,27 +4196,6 @@ int apply_autostash_oid(const char *stash_oid)
 	return apply_save_autostash_oid(stash_oid, 1);
 }
 
-static const char *reflog_message(struct replay_opts *opts,
-	const char *sub_action, const char *fmt, ...)
-{
-	va_list ap;
-	static struct strbuf buf = STRBUF_INIT;
-	char *reflog_action = getenv(GIT_REFLOG_ACTION);
-
-	va_start(ap, fmt);
-	strbuf_reset(&buf);
-	strbuf_addstr(&buf, reflog_action ? reflog_action : action_name(opts));
-	if (sub_action)
-		strbuf_addf(&buf, " (%s)", sub_action);
-	if (fmt) {
-		strbuf_addstr(&buf, ": ");
-		strbuf_vaddf(&buf, fmt, ap);
-	}
-	va_end(ap);
-
-	return buf.buf;
-}
-
 static int run_git_checkout(struct repository *r, struct replay_opts *opts,
 			    const char *commit, const char *action)
 {
-- 
2.32.0-dev
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 29 of 33 in “add missing __attribute__((format))”
  1. 0/6 add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 10, 2021
  2. 1/6 *.c static functions: don't forward-declare __attribute__Ævar Arnfjörð Bjarmason, Jul 10, 2021
  3. 3/6 *.c static functions: add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 10, 2021
  4. 5/6 bugreport.c: tweak cmd_bugreport() to use __attribute__((printf))Ævar Arnfjörð Bjarmason, Jul 10, 2021
  5. Junio C HamanoJul 12, 2021
  6. 2/6 sequencer.c: move static function to avoid forward declÆvar Arnfjörð Bjarmason, Jul 10, 2021
  7. 6/6 git-compat-util.h: add __attribute__((printf)) to git_*printf*Ævar Arnfjörð Bjarmason, Jul 10, 2021
  8. Jeff KingJul 12, 2021
  9. Randall S. BeckerJul 12, 2021
  10. Jeff KingJul 12, 2021
  11. Randall S. BeckerJul 12, 2021
  12. 4/6 *.h: add a few missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 10, 2021
  13. Ævar Arnfjörð BjarmasonJul 11, 2021
  14. Jeff KingJul 12, 2021
  15. Jeff KingJul 12, 2021
  16. 0/6 add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 13, 2021
  17. 1/6 *.c static functions: don't forward-declare __attribute__Ævar Arnfjörð Bjarmason, Jul 13, 2021
  18. 2/6 sequencer.c: move static function to avoid forward declÆvar Arnfjörð Bjarmason, Jul 13, 2021
  19. 3/6 *.c static functions: add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 13, 2021
  20. 4/6 *.h: add a few missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 13, 2021
  21. 5/6 advice.h: add missing __attribute__((format)) & fix usageÆvar Arnfjörð Bjarmason, Jul 13, 2021
  22. 6/6 strbuf.h: add a comment about "missing" strftime() checkingÆvar Arnfjörð Bjarmason, Jul 13, 2021
  23. Jeff KingJul 13, 2021
  24. Jeff KingJul 13, 2021
  25. Junio C HamanoJul 13, 2021
  26. Ævar Arnfjörð BjarmasonJul 13, 2021
  27. 0/5 add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 14, 2021
  28. 1/5 *.c static functions: don't forward-declare __attribute__Ævar Arnfjörð Bjarmason, Jul 14, 2021
  29. 2/5 sequencer.c: move static function to avoid forward declÆvar Arnfjörð Bjarmason, Jul 14, 2021
  30. 3/5 *.c static functions: add missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 14, 2021
  31. 5/5 advice.h: add missing __attribute__((format)) & fix usageÆvar Arnfjörð Bjarmason, Jul 14, 2021
  32. 4/5 *.h: add a few missing __attribute__((format))Ævar Arnfjörð Bjarmason, Jul 14, 2021
  33. Junio C HamanoJul 14, 2021

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.