]> git.ipfire.org Git - thirdparty/git.git/commitdiff
update-ref: move `print_rejected_refs()` up
authorKarthik Nayak <karthik.188@gmail.com>
Mon, 27 Apr 2026 10:42:06 +0000 (12:42 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Apr 2026 12:35:12 +0000 (21:35 +0900)
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>
builtin/update-ref.c

index 2d68c40ecb70108393865adebc608d9854b04f7a..5259cc72267918028b41a0ddf2aa2883b6881b23 100644 (file)
@@ -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)
 {