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
index 2d68c40ecb..5259cc7226 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -234,6 +234,28 @@ static int parse_next_oid(const char **next, const char *end,
command, refname);
}
+static void print_rejected_refs(const char *refname,
+ const struct object_id *old_oid,
+ const struct object_id *new_oid,
+ const char *old_target,
+ const char *new_target,
+ enum ref_transaction_error err,
+ const char *details,
+ void *cb_data UNUSED)
+{
+ struct strbuf sb = STRBUF_INIT;
+
+ if (details && *details)
+ error("%s", details);
+
+ strbuf_addf(&sb, "rejected %s %s %s %s\n", refname,
+ new_oid ? oid_to_hex(new_oid) : new_target,
+ old_oid ? oid_to_hex(old_oid) : old_target,
+ ref_transaction_error_msg(err));
+
+ fwrite(sb.buf, sb.len, 1, stdout);
+ strbuf_release(&sb);
+}
/*
* The following five parse_cmd_*() functions parse the corresponding
@@ -567,29 +589,6 @@ static void parse_cmd_abort(struct ref_transaction *transaction,
report_ok("abort");
}
-static void print_rejected_refs(const char *refname,
- const struct object_id *old_oid,
- const struct object_id *new_oid,
- const char *old_target,
- const char *new_target,
- enum ref_transaction_error err,
- const char *details,
- void *cb_data UNUSED)
-{
- struct strbuf sb = STRBUF_INIT;
-
- if (details && *details)
- error("%s", details);
-
- strbuf_addf(&sb, "rejected %s %s %s %s\n", refname,
- new_oid ? oid_to_hex(new_oid) : new_target,
- old_oid ? oid_to_hex(old_oid) : old_target,
- ref_transaction_error_msg(err));
-
- fwrite(sb.buf, sb.len, 1, stdout);
- strbuf_release(&sb);
-}
-
static void parse_cmd_commit(struct ref_transaction *transaction,
const char *next, const char *end UNUSED)
{