update-ref: move `print_rejected_refs()` up

The `print_rejected_refs()` function is used to print any rejected refs when using git-updated-ref(1) with the '--batch-updates' option. In the following commit, we'll need to use this function in another place, so move the function up to avoid a separate forward declaration. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Karthik Nayak committed May 4, 2026 at 19:44 UTC 637989cdec77b95fb0743cf433873253cec5ae0f
1 file changed +22 -23
builtin/update-ref.c
+22 -23
@@ -234,6 +234,28 @@ static int parse_next_oid(const char **next, const char *end,
234 command, refname);
235 }
236
237 +static void print_rejected_refs(const char *refname,
238 + const struct object_id *old_oid,
239 + const struct object_id *new_oid,
240 + const char *old_target,
241 + const char *new_target,
242 + enum ref_transaction_error err,
243 + const char *details,
244 + void *cb_data UNUSED)
245 +{
246 + struct strbuf sb = STRBUF_INIT;
247 +
248 + if (details && *details)
249 + error("%s", details);
250 +
251 + strbuf_addf(&sb, "rejected %s %s %s %s\n", refname,
252 + new_oid ? oid_to_hex(new_oid) : new_target,
253 + old_oid ? oid_to_hex(old_oid) : old_target,
254 + ref_transaction_error_msg(err));
255 +
256 + fwrite(sb.buf, sb.len, 1, stdout);
257 + strbuf_release(&sb);
258 +}
259
260 /*
261 * The following five parse_cmd_*() functions parse the corresponding
@@ -567,29 +589,6 @@ static void parse_cmd_abort(struct ref_transaction *transaction,
589 report_ok("abort");
590 }
591
570 -static void print_rejected_refs(const char *refname,
571 - const struct object_id *old_oid,
572 - const struct object_id *new_oid,
573 - const char *old_target,
574 - const char *new_target,
575 - enum ref_transaction_error err,
576 - const char *details,
577 - void *cb_data UNUSED)
578 -{
579 - struct strbuf sb = STRBUF_INIT;
580 -
581 - if (details && *details)
582 - error("%s", details);
583 -
584 - strbuf_addf(&sb, "rejected %s %s %s %s\n", refname,
585 - new_oid ? oid_to_hex(new_oid) : new_target,
586 - old_oid ? oid_to_hex(old_oid) : old_target,
587 - ref_transaction_error_msg(err));
588 -
589 - fwrite(sb.buf, sb.len, 1, stdout);
590 - strbuf_release(&sb);
591 -}
592 -
592 static void parse_cmd_commit(struct ref_transaction *transaction,
593 const char *next, const char *end UNUSED)
594 {