From: Karthik Nayak Date: Mon, 27 Apr 2026 10:42:06 +0000 (+0200) Subject: update-ref: move `print_rejected_refs()` up X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=1769ff2405a73a6e02c47fcd9911b0925a8bf118;p=thirdparty%2Fgit.git 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin/update-ref.c b/builtin/update-ref.c 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) {