git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 5/9] update-ref: move `print_rejected_refs()` up

From
Karthik Nayak <karthik.188@gmail.com>
Date
Apr 23, 2026, 08:40 UTC
Message-ID
<20260423-refs-move-to-generic-layer-v2-5-ae5a4f146d7d@gmail.com>
In-Reply-To
<20260423-refs-move-to-generic-layer-v2-0-ae5a4f146d7d@gmail.com>

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>
---
 builtin/update-ref.c | 45 ++++++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 23 deletions(-)
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)
 {
-- 
2.53.GIT
Previous: Toon ClaesNext: Karthik Nayak
Message 31 of 68 in “refs: move some of the generic logic out of the backends”
  1. 0/8 refs: move some of the generic logic out of the backendsKarthik Nayak, Apr 20, 2026
  2. 1/8 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, Apr 20, 2026
  3. Patrick SteinhardtApr 22, 2026
  4. Karthik NayakApr 22, 2026
  5. 2/8 refs: extract out reflog config to generic layerKarthik Nayak, Apr 20, 2026
  6. Patrick SteinhardtApr 22, 2026
  7. Karthik NayakApr 22, 2026
  8. 3/8 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, Apr 20, 2026
  9. Patrick SteinhardtApr 22, 2026
  10. Karthik NayakApr 22, 2026
  11. 4/8 update-ref: move `print_rejected_refs()` upKarthik Nayak, Apr 20, 2026
  12. Patrick SteinhardtApr 22, 2026
  13. Karthik NayakApr 22, 2026
  14. 5/8 update-ref: handle rejections while adding updatesKarthik Nayak, Apr 20, 2026
  15. Patrick SteinhardtApr 22, 2026
  16. Karthik NayakApr 22, 2026
  17. 6/8 refs: move object parsing to the generic layerKarthik Nayak, Apr 20, 2026
  18. Patrick SteinhardtApr 22, 2026
  19. Karthik NayakApr 22, 2026
  20. 8/8 refs: use peeled tag values in reference backendsKarthik Nayak, Apr 20, 2026
  21. 7/8 refs: add peeled object ID to the `ref_update` structKarthik Nayak, Apr 20, 2026
  22. 0/9 refs: move some of the generic logic out of the backendsKarthik Nayak, Apr 23, 2026
  23. 1/9 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, Apr 23, 2026
  24. 2/9 refs: introduce `ref_store_init_options`Karthik Nayak, Apr 23, 2026
  25. Patrick SteinhardtApr 23, 2026
  26. Karthik NayakApr 24, 2026
  27. 3/9 refs: extract out reflog config to generic layerKarthik Nayak, Apr 23, 2026
  28. Patrick SteinhardtApr 23, 2026
  29. 4/9 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, Apr 23, 2026
  30. Toon ClaesApr 24, 2026
  31. 5/9 update-ref: move `print_rejected_refs()` upKarthik Nayak, Apr 23, 2026
  32. 6/9 update-ref: handle rejections while adding updatesKarthik Nayak, Apr 23, 2026
  33. Patrick SteinhardtApr 23, 2026
  34. Karthik NayakApr 24, 2026
  35. Toon ClaesApr 24, 2026
  36. Karthik NayakApr 27, 2026
  37. 7/9 refs: move object parsing to the generic layerKarthik Nayak, Apr 23, 2026
  38. Toon ClaesApr 24, 2026
  39. Karthik NayakApr 27, 2026
  40. 8/9 refs: add peeled object ID to the `ref_update` structKarthik Nayak, Apr 23, 2026
  41. Toon ClaesApr 24, 2026
  42. Karthik NayakApr 27, 2026
  43. 9/9 refs: use peeled tag values in reference backendsKarthik Nayak, Apr 23, 2026
  44. 0/9 refs: move some of the generic logic out of the backendsKarthik Nayak, Apr 27, 2026
  45. 1/9 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, Apr 27, 2026
  46. 2/9 refs: introduce `ref_store_init_options`Karthik Nayak, Apr 27, 2026
  47. 3/9 refs: extract out reflog config to generic layerKarthik Nayak, Apr 27, 2026
  48. 4/9 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, Apr 27, 2026
  49. 5/9 update-ref: move `print_rejected_refs()` upKarthik Nayak, Apr 27, 2026
  50. 6/9 update-ref: handle rejections while adding updatesKarthik Nayak, Apr 27, 2026
  51. Toon ClaesApr 29, 2026
  52. Karthik NayakApr 30, 2026
  53. 7/9 refs: move object parsing to the generic layerKarthik Nayak, Apr 27, 2026
  54. 8/9 refs: add peeled object ID to the `ref_update` structKarthik Nayak, Apr 27, 2026
  55. 9/9 refs: use peeled tag values in reference backendsKarthik Nayak, Apr 27, 2026
  56. 0/9 refs: move some of the generic logic out of the backendsKarthik Nayak, May 4, 2026
  57. 1/9 refs: remove unused typedef 'ref_transaction_commit_fn'Karthik Nayak, May 4, 2026
  58. 2/9 refs: introduce `ref_store_init_options`Karthik Nayak, May 4, 2026
  59. 3/9 refs: extract out reflog config to generic layerKarthik Nayak, May 4, 2026
  60. 4/9 refs: return `ref_transaction_error` from `ref_transaction_update()`Karthik Nayak, May 4, 2026
  61. 5/9 update-ref: move `print_rejected_refs()` upKarthik Nayak, May 4, 2026
  62. 6/9 update-ref: handle rejections while adding updatesKarthik Nayak, May 4, 2026
  63. Patrick SteinhardtMay 5, 2026
  64. Karthik NayakMay 5, 2026
  65. Toon ClaesMay 6, 2026
  66. 7/9 refs: move object parsing to the generic layerKarthik Nayak, May 4, 2026
  67. 8/9 refs: add peeled object ID to the `ref_update` structKarthik Nayak, May 4, 2026
  68. 9/9 refs: use peeled tag values in reference backendsKarthik Nayak, May 4, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.