sequencer.c: move static function to avoid forward decl
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Jul 10, 2021 at 10:47 UTC
d4ac305073411bd70ae94e79c8fe8130a7d378aa
1 file changed
+19
-22
sequencer.c
+19
-22
@@ -3599,7 +3599,25 @@ static int do_label(struct repository *r, const char *name, int len)
3599
}
3600
3601
static const char *reflog_message(struct replay_opts *opts,
3602
- const char *sub_action, const char *fmt, ...);
3602
+ const char *sub_action, const char *fmt, ...)
3603
+{
3604
+ va_list ap;
3605
+ static struct strbuf buf = STRBUF_INIT;
3606
+ char *reflog_action = getenv(GIT_REFLOG_ACTION);
3607
+
3608
+ va_start(ap, fmt);
3609
+ strbuf_reset(&buf);
3610
+ strbuf_addstr(&buf, reflog_action ? reflog_action : action_name(opts));
3611
+ if (sub_action)
3612
+ strbuf_addf(&buf, " (%s)", sub_action);
3613
+ if (fmt) {
3614
+ strbuf_addstr(&buf, ": ");
3615
+ strbuf_vaddf(&buf, fmt, ap);
3616
+ }
3617
+ va_end(ap);
3618
+
3619
+ return buf.buf;
3620
+}
3621
3622
static int do_reset(struct repository *r,
3623
const char *name, int len,
@@ -4178,27 +4196,6 @@ int apply_autostash_oid(const char *stash_oid)
4196
return apply_save_autostash_oid(stash_oid, 1);
4197
}
4198
4181
-static const char *reflog_message(struct replay_opts *opts,
4182
- const char *sub_action, const char *fmt, ...)
4183
-{
4184
- va_list ap;
4185
- static struct strbuf buf = STRBUF_INIT;
4186
- char *reflog_action = getenv(GIT_REFLOG_ACTION);
4187
-
4188
- va_start(ap, fmt);
4189
- strbuf_reset(&buf);
4190
- strbuf_addstr(&buf, reflog_action ? reflog_action : action_name(opts));
4191
- if (sub_action)
4192
- strbuf_addf(&buf, " (%s)", sub_action);
4193
- if (fmt) {
4194
- strbuf_addstr(&buf, ": ");
4195
- strbuf_vaddf(&buf, fmt, ap);
4196
- }
4197
- va_end(ap);
4198
-
4199
- return buf.buf;
4200
-}
4201
-
4199
static int run_git_checkout(struct repository *r, struct replay_opts *opts,
4200
const char *commit, const char *action)
4201
{