sequencer: move reflog message functions

In the next commit these functions will be called from pick_one_commit() so move them above that function to avoid a forward declaration. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed May 9, 2025 at 16:22 UTC 74727214639d7d8635f667111f4fd6a3295a18bb
1 file changed +33 -33
sequencer.c
+33 -33
@@ -2235,6 +2235,39 @@ static void refer_to_commit(struct replay_opts *opts,
2235 }
2236 }
2237
2238 +static const char *sequencer_reflog_action(struct replay_opts *opts)
2239 +{
2240 + if (!opts->reflog_action) {
2241 + opts->reflog_action = getenv(GIT_REFLOG_ACTION);
2242 + opts->reflog_action =
2243 + xstrdup(opts->reflog_action ? opts->reflog_action
2244 + : action_name(opts));
2245 + }
2246 +
2247 + return opts->reflog_action;
2248 +}
2249 +
2250 +__attribute__((format (printf, 3, 4)))
2251 +static const char *reflog_message(struct replay_opts *opts,
2252 + const char *sub_action, const char *fmt, ...)
2253 +{
2254 + va_list ap;
2255 + static struct strbuf buf = STRBUF_INIT;
2256 +
2257 + va_start(ap, fmt);
2258 + strbuf_reset(&buf);
2259 + strbuf_addstr(&buf, sequencer_reflog_action(opts));
2260 + if (sub_action)
2261 + strbuf_addf(&buf, " (%s)", sub_action);
2262 + if (fmt) {
2263 + strbuf_addstr(&buf, ": ");
2264 + strbuf_vaddf(&buf, fmt, ap);
2265 + }
2266 + va_end(ap);
2267 +
2268 + return buf.buf;
2269 +}
2270 +
2271 static int do_pick_commit(struct repository *r,
2272 struct todo_item *item,
2273 struct replay_opts *opts,
@@ -3922,39 +3955,6 @@ static int do_label(struct repository *r, const char *name, int len)
3955 return ret;
3956 }
3957
3925 -static const char *sequencer_reflog_action(struct replay_opts *opts)
3926 -{
3927 - if (!opts->reflog_action) {
3928 - opts->reflog_action = getenv(GIT_REFLOG_ACTION);
3929 - opts->reflog_action =
3930 - xstrdup(opts->reflog_action ? opts->reflog_action
3931 - : action_name(opts));
3932 - }
3933 -
3934 - return opts->reflog_action;
3935 -}
3936 -
3937 -__attribute__((format (printf, 3, 4)))
3938 -static const char *reflog_message(struct replay_opts *opts,
3939 - const char *sub_action, const char *fmt, ...)
3940 -{
3941 - va_list ap;
3942 - static struct strbuf buf = STRBUF_INIT;
3943 -
3944 - va_start(ap, fmt);
3945 - strbuf_reset(&buf);
3946 - strbuf_addstr(&buf, sequencer_reflog_action(opts));
3947 - if (sub_action)
3948 - strbuf_addf(&buf, " (%s)", sub_action);
3949 - if (fmt) {
3950 - strbuf_addstr(&buf, ": ");
3951 - strbuf_vaddf(&buf, fmt, ap);
3952 - }
3953 - va_end(ap);
3954 -
3955 - return buf.buf;
3956 -}
3957 -
3958 static struct commit *lookup_label(struct repository *r, const char *label,
3959 int len, struct strbuf *buf)
3960 {