{"thread":{"id":"64834","subject":"[PATCH v3 1/6] refs: skip to next ref when current ref is rejected","startedAt":"2026-01-20T09:59:38Z","lastAt":"2026-01-22T09:05:47Z","messageCount":11,"participants":["Karthik Nayak","Phillip Wood","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":6},"messages":[{"id":"534219","messageId":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-1-e0edb29acbef@gmail.com","threadId":"64834","inReplyTo":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-0-e0edb29acbef@gmail.com","subject":"[PATCH v3 1/6] refs: skip to next ref when current ref is rejected","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-01-20T09:59:19Z","receivedAt":"2026-01-20T09:59:38Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In `refs_verify_refnames_available()` we have two nested loops: the\nouter loop iterates over all references to check, while the inner loop\nchecks for filesystem conflicts for a given ref by breaking down its\npath.\n\nWith batched updates, when we detect a filesystem conflict, we mark the\nupdate as rejected and execute 'continue'. However, this only skips to\nthe next iteration of the inner loop, not the outer loop as intended.\nThis causes the same reference to be repeatedly rejected. Fix this by\nusing a goto statement to skip to the next reference in the outer loop.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n refs.c                  | 44 ++++++++++++++++++++++++++------------------\n refs/files-backend.c    |  5 ++---\n refs/packed-backend.c   | 12 ++++++------\n refs/refs-internal.h    |  4 +++-\n refs/reftable-backend.c |  5 ++---\n 5 files changed, 39 insertions(+), 31 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex e06e0cb072..53919c3d22 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1224,6 +1224,7 @@ void ref_transaction_free(struct ref_transaction *transaction)\n \t\tfree(transaction->updates[i]->committer_info);\n \t\tfree((char *)transaction->updates[i]->new_target);\n \t\tfree((char *)transaction->updates[i]->old_target);\n+\t\tfree((char *)transaction->updates[i]->rejection_details);\n \t\tfree(transaction->updates[i]);\n \t}\n \n@@ -1238,7 +1239,8 @@ void ref_transaction_free(struct ref_transaction *transaction)\n \n int ref_transaction_maybe_set_rejected(struct ref_transaction *transaction,\n \t\t\t\t       size_t update_idx,\n-\t\t\t\t       enum ref_transaction_error err)\n+\t\t\t\t       enum ref_transaction_error err,\n+\t\t\t\t       struct strbuf *details)\n {\n \tif (update_idx >= transaction->nr)\n \t\tBUG(\"trying to set rejection on invalid update index\");\n@@ -1264,6 +1266,7 @@ int ref_transaction_maybe_set_rejected(struct ref_transaction *transaction,\n \t\t\t   transaction->updates[update_idx]->refname, 0);\n \n \ttransaction->updates[update_idx]->rejection_err = err;\n+\ttransaction->updates[update_idx]->rejection_details = strbuf_detach(details, NULL);\n \tALLOC_GROW(transaction->rejections->update_indices,\n \t\t   transaction->rejections->nr + 1,\n \t\t   transaction->rejections->alloc);\n@@ -2659,30 +2662,33 @@ enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs\n \t\t\tif (!initial_transaction &&\n \t\t\t    (strset_contains(&conflicting_dirnames, dirname.buf) ||\n \t\t\t     !refs_read_raw_ref(refs, dirname.buf, &oid, &referent,\n-\t\t\t\t\t\t       &type, &ignore_errno))) {\n+\t\t\t\t\t\t&type, &ignore_errno))) {\n+\n+\t\t\t\tstrbuf_addf(err, _(\"'%s' exists; cannot create '%s'\"),\n+\t\t\t\t\t    dirname.buf, refname);\n+\n \t\t\t\tif (transaction && ref_transaction_maybe_set_rejected(\n \t\t\t\t\t    transaction, *update_idx,\n-\t\t\t\t\t    REF_TRANSACTION_ERROR_NAME_CONFLICT)) {\n+\t\t\t\t\t    REF_TRANSACTION_ERROR_NAME_CONFLICT, err)) {\n \t\t\t\t\tstrset_remove(&dirnames, dirname.buf);\n \t\t\t\t\tstrset_add(&conflicting_dirnames, dirname.buf);\n-\t\t\t\t\tcontinue;\n+\t\t\t\t\tgoto next_ref;\n \t\t\t\t}\n \n-\t\t\t\tstrbuf_addf(err, _(\"'%s' exists; cannot create '%s'\"),\n-\t\t\t\t\t    dirname.buf, refname);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n \n \t\t\tif (extras && string_list_has_string(extras, dirname.buf)) {\n+\t\t\t\tstrbuf_addf(err, _(\"cannot process '%s' and '%s' at the same time\"),\n+\t\t\t\t\t    refname, dirname.buf);\n+\n \t\t\t\tif (transaction && ref_transaction_maybe_set_rejected(\n \t\t\t\t\t    transaction, *update_idx,\n-\t\t\t\t\t    REF_TRANSACTION_ERROR_NAME_CONFLICT)) {\n+\t\t\t\t\t    REF_TRANSACTION_ERROR_NAME_CONFLICT, err)) {\n \t\t\t\t\tstrset_remove(&dirnames, dirname.buf);\n-\t\t\t\t\tcontinue;\n+\t\t\t\t\tgoto next_ref;\n \t\t\t\t}\n \n-\t\t\t\tstrbuf_addf(err, _(\"cannot process '%s' and '%s' at the same time\"),\n-\t\t\t\t\t    refname, dirname.buf);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n \t\t}\n@@ -2712,14 +2718,14 @@ enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs\n \t\t\t\tif (skip &&\n \t\t\t\t    string_list_has_string(skip, iter->ref.name))\n \t\t\t\t\tcontinue;\n+\t\t\t\tstrbuf_addf(err, _(\"'%s' exists; cannot create '%s'\"),\n+\t\t\t\t\t    iter->ref.name, refname);\n \n \t\t\t\tif (transaction && ref_transaction_maybe_set_rejected(\n \t\t\t\t\t    transaction, *update_idx,\n-\t\t\t\t\t    REF_TRANSACTION_ERROR_NAME_CONFLICT))\n-\t\t\t\t\tcontinue;\n+\t\t\t\t\t    REF_TRANSACTION_ERROR_NAME_CONFLICT, err))\n+\t\t\t\t\tgoto next_ref;\n \n-\t\t\t\tstrbuf_addf(err, _(\"'%s' exists; cannot create '%s'\"),\n-\t\t\t\t\t    iter->ref.name, refname);\n \t\t\t\tgoto cleanup;\n \t\t\t}\n \n@@ -2729,15 +2735,17 @@ enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs\n \n \t\textra_refname = find_descendant_ref(dirname.buf, extras, skip);\n \t\tif (extra_refname) {\n+\t\t\tstrbuf_addf(err, _(\"cannot process '%s' and '%s' at the same time\"),\n+\t\t\t\t    refname, extra_refname);\n+\n \t\t\tif (transaction && ref_transaction_maybe_set_rejected(\n \t\t\t\t    transaction, *update_idx,\n-\t\t\t\t    REF_TRANSACTION_ERROR_NAME_CONFLICT))\n-\t\t\t\tcontinue;\n+\t\t\t\t    REF_TRANSACTION_ERROR_NAME_CONFLICT, err))\n+\t\t\t\tgoto next_ref;\n \n-\t\t\tstrbuf_addf(err, _(\"cannot process '%s' and '%s' at the same time\"),\n-\t\t\t\t    refname, extra_refname);\n \t\t\tgoto cleanup;\n \t\t}\n+next_ref:;\n \t}\n \n \tret = 0;\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 6f6f76a8d8..6790d8bf53 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -2983,10 +2983,9 @@ static int files_transaction_prepare(struct ref_store *ref_store,\n \t\t\t\t\t  head_ref, &refnames_to_check,\n \t\t\t\t\t  err);\n \t\tif (ret) {\n-\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i, ret)) {\n-\t\t\t\tstrbuf_reset(err);\n+\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i,\n+\t\t\t\t\t\t\t       ret, err)) {\n \t\t\t\tret = 0;\n-\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tgoto cleanup;\ndiff --git a/refs/packed-backend.c b/refs/packed-backend.c\nindex 4ea0c12299..59b3ecb9d6 100644\n--- a/refs/packed-backend.c\n+++ b/refs/packed-backend.c\n@@ -1437,8 +1437,8 @@ static enum ref_transaction_error write_with_updates(struct packed_ref_store *re\n \t\t\t\t\t\t    update->refname);\n \t\t\t\t\tret = REF_TRANSACTION_ERROR_CREATE_EXISTS;\n \n-\t\t\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i, ret)) {\n-\t\t\t\t\t\tstrbuf_reset(err);\n+\t\t\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i,\n+\t\t\t\t\t\t\t\t\t       ret, err)) {\n \t\t\t\t\t\tret = 0;\n \t\t\t\t\t\tcontinue;\n \t\t\t\t\t}\n@@ -1452,8 +1452,8 @@ static enum ref_transaction_error write_with_updates(struct packed_ref_store *re\n \t\t\t\t\t\t    oid_to_hex(&update->old_oid));\n \t\t\t\t\tret = REF_TRANSACTION_ERROR_INCORRECT_OLD_VALUE;\n \n-\t\t\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i, ret)) {\n-\t\t\t\t\t\tstrbuf_reset(err);\n+\t\t\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i,\n+\t\t\t\t\t\t\t\t\t       ret, err)) {\n \t\t\t\t\t\tret = 0;\n \t\t\t\t\t\tcontinue;\n \t\t\t\t\t}\n@@ -1496,8 +1496,8 @@ static enum ref_transaction_error write_with_updates(struct packed_ref_store *re\n \t\t\t\t\t    oid_to_hex(&update->old_oid));\n \t\t\t\tret = REF_TRANSACTION_ERROR_NONEXISTENT_REF;\n \n-\t\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i, ret)) {\n-\t\t\t\t\tstrbuf_reset(err);\n+\t\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i,\n+\t\t\t\t\t\t\t\t       ret, err)) {\n \t\t\t\t\tret = 0;\n \t\t\t\t\tcontinue;\n \t\t\t\t}\ndiff --git a/refs/refs-internal.h b/refs/refs-internal.h\nindex c7d2a6e50b..191a25683f 100644\n--- a/refs/refs-internal.h\n+++ b/refs/refs-internal.h\n@@ -128,6 +128,7 @@ struct ref_update {\n \t * was rejected.\n \t */\n \tenum ref_transaction_error rejection_err;\n+\tconst char *rejection_details;\n \n \t/*\n \t * If this ref_update was split off of a symref update via\n@@ -153,7 +154,8 @@ int refs_read_raw_ref(struct ref_store *ref_store, const char *refname,\n  */\n int ref_transaction_maybe_set_rejected(struct ref_transaction *transaction,\n \t\t\t\t       size_t update_idx,\n-\t\t\t\t       enum ref_transaction_error err);\n+\t\t\t\t       enum ref_transaction_error err,\n+\t\t\t\t       struct strbuf *details);\n \n /*\n  * Add a ref_update with the specified properties to transaction, and\ndiff --git a/refs/reftable-backend.c b/refs/reftable-backend.c\nindex 4319a4eacb..0e2648e36c 100644\n--- a/refs/reftable-backend.c\n+++ b/refs/reftable-backend.c\n@@ -1401,10 +1401,9 @@ static int reftable_be_transaction_prepare(struct ref_store *ref_store,\n \t\t\t\t\t    &refnames_to_check, head_type,\n \t\t\t\t\t    &head_referent, &referent, err);\n \t\tif (ret) {\n-\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i, ret)) {\n-\t\t\t\tstrbuf_reset(err);\n+\t\t\tif (ref_transaction_maybe_set_rejected(transaction, i,\n+\t\t\t\t\t\t\t       ret, err)) {\n \t\t\t\tret = 0;\n-\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tgoto done;\n\n-- \n2.51.2\n\n"},{"id":"534220","messageId":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-0-e0edb29acbef@gmail.com","threadId":"64834","inReplyTo":"20260114-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v1-0-f5f8b173c501@gmail.com","subject":"[PATCH v3 0/6] refs: provide detailed error messages when using batched update","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-01-20T09:59:18Z","receivedAt":"2026-01-20T09:59:38Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The refs namespace uses an error buffer to capture details about failed\nreference updates. However when we added batched update support to\nreference transactions, these messages were never propagated, instead\nonly an error code pertaining to the type of failure was propagated.\n\nCurrently, there are three regions which utilize batched updates:\n\n  - git update-ref --batch-updates\n  - git fetch\n  - git receive-pack\n\nWhile 'git update-ref --batch-updates' was a newly introduced flag, both\n'git fetch' and 'git receive-pack' were pre-existing. Before using\nbatched updates, they provided more detailed error messages to the user,\nbut this changed with the introduction of batched updates. This is a\nregression in their workings.\n\nThis patch series fixes this, by passing the detailed error message and\nutilizing it whenever available. The regression was reported by Elijah\nNewren [1] and based on the patch submitted by Jeff King [2].\n\n[1]: https://lore.kernel.org/all/CABPp-BGL2tJR4dPidQuFcp-X0_VkVTknCY-0Zgo=jHVGv_P=wA@mail.gmail.com/\n[2]: https://lore.kernel.org/all/20251224081214.GA1879908@coredump.intra.peff.net/\n\n---\nChanges in v3:\n- Drop the first commit.\n- For the last commit, where we delay 'git fetch' status information,\n  delay all information to the end. Also use a list to compliment the\n  existing strmap, this ensures that the order is maintained.\n- Link to v2: https://patch.msgid.link/20260116-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v2-0-925a0e9c7f32@gmail.com\n\nChanges in v2:\n- Updates to the commit messages to be more descriptive.\n- Instead of passing the char pointer for the error description, pass\n  the 'strbuf' itself. This makes the API a lot cleaner to deal with.\n  Also avoids having to remember to reset the strbuf after usage.\n- Chalk out a separate commit for using a 'goto next_ref' in\n  `refs_verify_refnames_available()`. This makes the intention much\n  clearer.\n- For git-update-ref(1), keep the existing implementation as is and only\n  output the detailed error message to stderr.\n- For git-receive-pack(1), use 'rp_error()' for detailed error message\n  while keeping the current implementation as is.\n- Added a separate patch to handle missing information in git-fetch(1)'s\n  status table. This involves delaying updates to the end, where update\n  success/failure information is available. I'm not too confident about\n  this approach though, we could also drop it from the series and I\n  could pick that up independently. This is still 1.19 ± 0.02 times\n  faster than non-batched version (v2.50.0) in the files backend.\n- Link to v1: https://patch.msgid.link/20260114-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v1-0-f5f8b173c501@gmail.com\n\n---\n builtin/fetch.c         | 259 +++++++++++++++++++++++++++++++++++++-----------\n builtin/receive-pack.c  |   7 +-\n builtin/update-ref.c    |   7 +-\n refs.c                  |  46 +++++----\n refs.h                  |   1 +\n refs/files-backend.c    |   5 +-\n refs/packed-backend.c   |  12 +--\n refs/refs-internal.h    |   4 +-\n refs/reftable-backend.c |   5 +-\n t/t1400-update-ref.sh   |  71 +++++++------\n t/t5510-fetch.sh        |   8 +-\n t/t5516-fetch-push.sh   |  16 +++\n 12 files changed, 316 insertions(+), 125 deletions(-)\n\nKarthik Nayak (6):\n      refs: skip to next ref when current ref is rejected\n      refs: add rejection detail to the callback function\n      update-ref: utilize rejected error details if available\n      fetch: utilize rejected ref error details\n      receive-pack: utilize rejected ref error details\n      fetch: delay user information post committing of transaction\n\nRange-diff versus v2:\n\n1:  7592b0a9aa < -:  ---------- refs: drop unnecessary header includes\n2:  97095095bc = 1:  dbabb9a172 refs: skip to next ref when current ref is rejected\n3:  2dadab77a2 = 2:  b0ab39a262 refs: add rejection detail to the callback function\n4:  007c6d58c1 = 3:  2b323bddbc update-ref: utilize rejected error details if available\n5:  0d0b8b75c8 = 4:  8bf3d986f4 fetch: utilize rejected ref error details\n6:  b9348b5ae3 = 5:  5dab402570 receive-pack: utilize rejected ref error details\n7:  d90420903f ! 6:  596762e6b5 fetch: delay user information post committing of transaction\n    @@ Commit message\n         `ref_update_display_info` which will hold individual update's\n         information and also whether the update failed or succeeded. This\n         finally allows us to iterate over all such updates and print them to the\n    -    user. While this brings back the functionality, it does change the order\n    -    of the output. Modify the tests to reflect this.\n    +    user.\n     \n    -    Using an strmap does add some overhead to 'git-fetch(1)', but from\n    -    benchmarking this seems to be not too bad:\n    +    Using an dynamic array and strmap does add some overhead to\n    +    'git-fetch(1)', but from benchmarking this seems to be not too bad:\n     \n           Benchmark 1: fetch: many refs (refformat = files, refcount = 1000, revision = master)\n    -        Time (mean ± σ):      51.9 ms ±   2.5 ms    [User: 15.6 ms, System: 36.9 ms]\n    -        Range (min … max):    47.4 ms …  58.3 ms    41 runs\n    +        Time (mean ± σ):      42.6 ms ±   1.2 ms    [User: 13.1 ms, System: 29.8 ms]\n    +        Range (min … max):    40.1 ms …  45.8 ms    47 runs\n     \n           Benchmark 2: fetch: many refs (refformat = files, refcount = 1000, revision = HEAD)\n    -        Time (mean ± σ):      53.0 ms ±   1.8 ms    [User: 17.6 ms, System: 36.0 ms]\n    -        Range (min … max):    49.4 ms …  57.6 ms    40 runs\n    +        Time (mean ± σ):      43.1 ms ±   1.2 ms    [User: 12.7 ms, System: 30.7 ms]\n    +        Range (min … max):    40.5 ms …  45.8 ms    48 runs\n     \n           Summary\n             fetch: many refs (refformat = files, refcount = 1000, revision = master) ran\n    -          1.02 ± 0.06 times faster than fetch: many refs (refformat = files, refcount = 1000, revision = HEAD)\n    +          1.01 ± 0.04 times faster than fetch: many refs (refformat = files, refcount = 1000, revision = HEAD)\n     \n         Another approach would be to move the status printing logic to be\n         handled post the transaction being committed. That however would require\n    @@ Commit message\n         which is more involved infrastructure work compared to the strmap\n         approach here.\n     \n    +    Helped-by: Phillip Wood <phillip.wood123@gmail.com>\n         Reported-by: Jeff King <peff@peff.net>\n         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n     \n    @@ builtin/fetch.c: static void display_ref_update(struct display_state *display_st\n     +\tconst char *summary;\n     +\tconst char *fail_detail;\n     +\tconst char *success_detail;\n    ++\tconst char *ref;\n     +\tconst char *remote;\n    -+\tconst char *local;\n     +\tstruct object_id old_oid;\n     +\tstruct object_id new_oid;\n     +};\n     +\n    -+static struct ref_update_display_info *ref_update_display_info_new(\n    -+\t\t\t\t\t\tchar success_code,\n    -+\t\t\t\t\t\tchar fail_code,\n    -+\t\t\t\t\t\tconst char *summary,\n    -+\t\t\t\t\t\tconst char *success_detail,\n    -+\t\t\t\t\t\tconst char *fail_detail,\n    -+\t\t\t\t\t\tconst char *remote,\n    -+\t\t\t\t\t\tconst struct object_id *old_oid,\n    -+\t\t\t\t\t\tconst struct object_id *new_oid)\n    ++static struct ref_update_display_info *ref_update_display_info_append(\n    ++\t\t\t\t\t   struct ref_update_display_info **list,\n    ++\t\t\t\t\t   size_t *count,\n    ++\t\t\t\t\t   char success_code,\n    ++\t\t\t\t\t   char fail_code,\n    ++\t\t\t\t\t   const char *summary,\n    ++\t\t\t\t\t   const char *success_detail,\n    ++\t\t\t\t\t   const char *fail_detail,\n    ++\t\t\t\t\t   const char *ref,\n    ++\t\t\t\t\t   const char *remote,\n    ++\t\t\t\t\t   const struct object_id *old_oid,\n    ++\t\t\t\t\t   const struct object_id *new_oid)\n     +{\n     +\tstruct ref_update_display_info *info;\n    -+\tCALLOC_ARRAY(info, 1);\n    ++\tsize_t index = *count;\n     +\n    ++\t(*count)++;\n    ++\tREALLOC_ARRAY(*list, *count);\n    ++\n    ++\tinfo = &(*list)[index];\n    ++\n    ++\tinfo->failed = false;\n     +\tinfo->success_code = success_code;\n     +\tinfo->fail_code = fail_code;\n     +\tinfo->summary = xstrdup(summary);\n     +\tinfo->success_detail = xstrdup_or_null(success_detail);\n     +\tinfo->fail_detail = xstrdup_or_null(fail_detail);\n     +\tinfo->remote = xstrdup(remote);\n    ++\tinfo->ref = xstrdup(ref);\n     +\n     +\toidcpy(&info->old_oid, old_oid);\n     +\toidcpy(&info->new_oid, new_oid);\n    @@ builtin/fetch.c: static void display_ref_update(struct display_state *display_st\n     +\tfree((char *)info->success_detail);\n     +\tfree((char *)info->fail_detail);\n     +\tfree((char *)info->remote);\n    ++\tfree((char *)info->ref);\n     +}\n     +\n     +static void ref_update_display_info_display(struct ref_update_display_info *info,\n     +\t\t\t\t\t    struct display_state *display_state,\n    -+\t\t\t\t\t    const char *refname, int summary_width)\n    ++\t\t\t\t\t    int summary_width)\n     +{\n     +\tdisplay_ref_update(display_state,\n     +\t\t\t   info->failed ? info->fail_code : info->success_code,\n     +\t\t\t   info->summary,\n     +\t\t\t   info->failed ? info->fail_detail : info->success_detail,\n    -+\t\t\t   info->remote, refname, &info->old_oid,\n    ++\t\t\t   info->remote, info->ref, &info->old_oid,\n     +\t\t\t   &info->new_oid, summary_width);\n     +}\n     +\n      static int update_local_ref(struct ref *ref,\n      \t\t\t    struct ref_transaction *transaction,\n    - \t\t\t    struct display_state *display_state,\n    +-\t\t\t    struct display_state *display_state,\n      \t\t\t    const struct ref *remote_ref,\n    - \t\t\t    int summary_width,\n    +-\t\t\t    int summary_width,\n     -\t\t\t    const struct fetch_config *config)\n     +\t\t\t    const struct fetch_config *config,\n    -+\t\t\t    struct strmap *delayed_ref_display)\n    ++\t\t\t    struct ref_update_display_info **display_list,\n    ++\t\t\t    size_t *display_count)\n      {\n      \tstruct commit *current = NULL, *updated;\n      \tint fast_forward = 0;\n     @@ builtin/fetch.c: static int update_local_ref(struct ref *ref,\n    + \n    + \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n    + \t\tif (verbosity > 0)\n    +-\t\t\tdisplay_ref_update(display_state, '=', _(\"[up to date]\"), NULL,\n    +-\t\t\t\t\t   remote_ref->name, ref->name,\n    +-\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n    ++\t\t\tref_update_display_info_append(display_list, display_count,\n    ++\t\t\t\t\t\t       '=', '=', _(\"[up to date]\"),\n    ++\t\t\t\t\t\t       NULL, NULL, ref->name,\n    ++\t\t\t\t\t\t       remote_ref->name, &ref->old_oid,\n    ++\t\t\t\t\t\t       &ref->new_oid);\n    + \t\treturn 0;\n    + \t}\n    + \n    + \tif (!update_head_ok &&\n    + \t    !is_null_oid(&ref->old_oid) &&\n    + \t    branch_checked_out(ref->name)) {\n    ++\t\tstruct ref_update_display_info *info;\n    + \t\t/*\n    + \t\t * If this is the head, and it's not okay to update\n    + \t\t * the head, and the old value of the head isn't empty...\n    + \t\t */\n    +-\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"),\n    +-\t\t\t\t   _(\"can't fetch into checked-out branch\"),\n    +-\t\t\t\t   remote_ref->name, ref->name,\n    +-\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n    ++\t\tinfo = ref_update_display_info_append(display_list, display_count,\n    ++\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"),\n    ++\t\t\t\t\t\t      NULL, _(\"can't fetch into checked-out branch\"),\n    ++\t\t\t\t\t\t      ref->name, remote_ref->name,\n    ++\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n    ++\t\tref_update_display_info_set_failed(info);\n    + \t\treturn 1;\n    + \t}\n    + \n      \tif (!is_null_oid(&ref->old_oid) &&\n      \t    starts_with(ref->name, \"refs/tags/\")) {\n    ++\t\tstruct ref_update_display_info *info;\n    ++\n      \t\tif (force || ref->force) {\n    -+\t\t\tstruct ref_update_display_info *info;\n      \t\t\tint r;\n     +\n      \t\t\tr = s_update_ref(\"updating tag\", ref, transaction, 0);\n    @@ builtin/fetch.c: static int update_local_ref(struct ref *ref,\n     -\t\t\t\t\t   remote_ref->name, ref->name,\n     -\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n     +\n    -+\t\t\tinfo = ref_update_display_info_new('t', '!', _(\"[tag update]\"), NULL,\n    -+\t\t\t\t\t\t\t   _(\"unable to update local ref\"),\n    -+\t\t\t\t\t\t\t   remote_ref->name, &ref->old_oid,\n    -+\t\t\t\t\t\t\t   &ref->new_oid);\n    ++\t\t\tinfo = ref_update_display_info_append(display_list, display_count,\n    ++\t\t\t\t\t\t\t      't', '!', _(\"[tag update]\"), NULL,\n    ++\t\t\t\t\t\t\t      _(\"unable to update local ref\"),\n    ++\t\t\t\t\t\t\t      ref->name, remote_ref->name,\n    ++\t\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n     +\t\t\tif (r)\n     +\t\t\t\tref_update_display_info_set_failed(info);\n    -+\t\t\tstrmap_put(delayed_ref_display, ref->name, info);\n     +\n      \t\t\treturn r;\n      \t\t} else {\n    - \t\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"),\n    +-\t\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"),\n    +-\t\t\t\t\t   _(\"would clobber existing tag\"),\n    +-\t\t\t\t\t   remote_ref->name, ref->name,\n    +-\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n    ++\t\t\tinfo = ref_update_display_info_append(display_list, display_count,\n    ++\t\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"), NULL,\n    ++\t\t\t\t\t\t\t      _(\"would clobber existing tag\"),\n    ++\t\t\t\t\t\t\t      ref->name, remote_ref->name,\n    ++\t\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n    ++\t\t\tref_update_display_info_set_failed(info);\n    + \t\t\treturn 1;\n    + \t\t}\n    + \t}\n     @@ builtin/fetch.c: static int update_local_ref(struct ref *ref,\n      \tupdated = lookup_commit_reference_gently(the_repository,\n      \t\t\t\t\t\t &ref->new_oid, 1);\n    @@ builtin/fetch.c: static int update_local_ref(struct ref *ref,\n     -\t\t\t\t   remote_ref->name, ref->name,\n     -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n     +\n    -+\t\tinfo = ref_update_display_info_new('*', '!', what, NULL,\n    -+\t\t\t\t\t\t   _(\"unable to update local ref\"),\n    -+\t\t\t\t\t\t   remote_ref->name, &ref->old_oid,\n    -+\t\t\t\t\t\t   &ref->new_oid);\n    ++\t\tinfo = ref_update_display_info_append(display_list, display_count,\n    ++\t\t\t\t\t\t      '*', '!', what, NULL,\n    ++\t\t\t\t\t\t      _(\"unable to update local ref\"),\n    ++\t\t\t\t\t\t      ref->name, remote_ref->name,\n    ++\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n     +\t\tif (r)\n     +\t\t\tref_update_display_info_set_failed(info);\n    -+\t\tstrmap_put(delayed_ref_display, ref->name, info);\n     +\n      \t\treturn r;\n      \t}\n    @@ builtin/fetch.c: static int update_local_ref(struct ref *ref,\n     -\t\t\t\t   remote_ref->name, ref->name,\n     -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n     +\n    -+\t\tinfo = ref_update_display_info_new(' ', '!', quickref.buf, NULL,\n    -+\t\t\t\t\t\t   _(\"unable to update local ref\"),\n    -+\t\t\t\t\t\t   remote_ref->name, &ref->old_oid,\n    -+\t\t\t\t\t\t   &ref->new_oid);\n    ++\t\tinfo = ref_update_display_info_append(display_list, display_count,\n    ++\t\t\t\t\t\t      ' ', '!', quickref.buf, NULL,\n    ++\t\t\t\t\t\t      _(\"unable to update local ref\"),\n    ++\t\t\t\t\t\t      ref->name, remote_ref->name,\n    ++\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n     +\t\tif (r)\n     +\t\t\tref_update_display_info_set_failed(info);\n    -+\t\tstrmap_put(delayed_ref_display, ref->name, info);\n     +\n      \t\tstrbuf_release(&quickref);\n      \t\treturn r;\n    @@ builtin/fetch.c: static int update_local_ref(struct ref *ref,\n     -\t\t\t\t   remote_ref->name, ref->name,\n     -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n     +\n    -+\t\tinfo = ref_update_display_info_new('+', '!', quickref.buf,\n    -+\t\t\t\t\t\t   _(\"forced update\"),\n    -+\t\t\t\t\t\t   _(\"unable to update local ref\"),\n    -+\t\t\t\t\t\t   remote_ref->name, &ref->old_oid,\n    -+\t\t\t\t\t\t   &ref->new_oid);\n    ++\t\tinfo = ref_update_display_info_append(display_list, display_count,\n    ++\t\t\t\t\t\t      '+', '!', quickref.buf, _(\"forced update\"),\n    ++\t\t\t\t\t\t      _(\"unable to update local ref\"),\n    ++\t\t\t\t\t\t      ref->name, remote_ref->name,\n    ++\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n    ++\n     +\t\tif (r)\n     +\t\t\tref_update_display_info_set_failed(info);\n    -+\t\tstrmap_put(delayed_ref_display, ref->name, info);\n     +\n      \t\tstrbuf_release(&quickref);\n      \t\treturn r;\n      \t} else {\n    +-\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"), _(\"non-fast-forward\"),\n    +-\t\t\t\t   remote_ref->name, ref->name,\n    +-\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n    ++\t\tstruct ref_update_display_info *info;\n    ++\t\tinfo = ref_update_display_info_append(display_list, display_count,\n    ++\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"), NULL,\n    ++\t\t\t\t\t\t      _(\"non-fast-forward\"),\n    ++\t\t\t\t\t\t      ref->name, remote_ref->name,\n    ++\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n    ++\t\tref_update_display_info_set_failed(info);\n    + \t\treturn 1;\n    + \t}\n    + }\n     @@ builtin/fetch.c: static int store_updated_refs(struct display_state *display_state,\n      \t\t\t      int connectivity_checked,\n      \t\t\t      struct ref_transaction *transaction, struct ref *ref_map,\n      \t\t\t      struct fetch_head *fetch_head,\n     -\t\t\t      const struct fetch_config *config)\n     +\t\t\t      const struct fetch_config *config,\n    -+\t\t\t      struct strmap *delayed_ref_display)\n    ++\t\t\t      struct ref_update_display_info **display_list,\n    ++\t\t\t      size_t *display_count)\n      {\n      \tint rc = 0;\n      \tstruct strbuf note = STRBUF_INIT;\n    + \tconst char *what, *kind;\n    + \tstruct ref *rm;\n    + \tint want_status;\n    +-\tint summary_width = 0;\n    +-\n    +-\tif (verbosity >= 0)\n    +-\t\tsummary_width = transport_summary_width(ref_map);\n    + \n    + \tif (!connectivity_checked) {\n    + \t\tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n     @@ builtin/fetch.c: static int store_updated_refs(struct display_state *display_state,\n    + \t\t\t\t\t  display_state->url_len);\n      \n      \t\t\tif (ref) {\n    - \t\t\t\trc |= update_local_ref(ref, transaction, display_state,\n    +-\t\t\t\trc |= update_local_ref(ref, transaction, display_state,\n     -\t\t\t\t\t\t       rm, summary_width, config);\n    -+\t\t\t\t\t\t       rm, summary_width, config,\n    -+\t\t\t\t\t\t       delayed_ref_display);\n    ++\t\t\t\trc |= update_local_ref(ref, transaction, rm,\n    ++\t\t\t\t\t\t       config, display_list,\n    ++\t\t\t\t\t\t       display_count);\n      \t\t\t\tfree(ref);\n      \t\t\t} else if (write_fetch_head || dry_run) {\n      \t\t\t\t/*\n    +@@ builtin/fetch.c: static int store_updated_refs(struct display_state *display_state,\n    + \t\t\t\t * would be written to FETCH_HEAD, if --dry-run\n    + \t\t\t\t * is set).\n    + \t\t\t\t */\n    +-\t\t\t\tdisplay_ref_update(display_state, '*',\n    +-\t\t\t\t\t\t   *kind ? kind : \"branch\", NULL,\n    +-\t\t\t\t\t\t   rm->name,\n    +-\t\t\t\t\t\t   \"FETCH_HEAD\",\n    +-\t\t\t\t\t\t   &rm->new_oid, &rm->old_oid,\n    +-\t\t\t\t\t\t   summary_width);\n    ++\n    ++\t\t\t\tref_update_display_info_append(display_list, display_count,\n    ++\t\t\t\t\t\t\t       '*', '*', *kind ? kind : \"branch\",\n    ++\t\t\t\t\t\t\t       NULL, NULL, \"FETCH_HEAD\", rm->name,\n    ++\t\t\t\t\t\t\t       &rm->new_oid, &rm->old_oid);\n    + \t\t\t}\n    + \t\t}\n    + \t}\n     @@ builtin/fetch.c: static int fetch_and_consume_refs(struct display_state *display_state,\n      \t\t\t\t  struct ref_transaction *transaction,\n      \t\t\t\t  struct ref *ref_map,\n      \t\t\t\t  struct fetch_head *fetch_head,\n     -\t\t\t\t  const struct fetch_config *config)\n     +\t\t\t\t  const struct fetch_config *config,\n    -+\t\t\t\t  struct strmap *delayed_ref_display)\n    ++\t\t\t\t  struct ref_update_display_info **display_list,\n    ++\t\t\t\t  size_t *display_count)\n      {\n      \tint connectivity_checked = 1;\n      \tint ret;\n    @@ builtin/fetch.c: static int fetch_and_consume_refs(struct display_state *display\n      \tret = store_updated_refs(display_state, connectivity_checked,\n     -\t\t\t\t transaction, ref_map, fetch_head, config);\n     +\t\t\t\t transaction, ref_map, fetch_head, config,\n    -+\t\t\t\t delayed_ref_display);\n    ++\t\t\t\t display_list, display_count);\n      \ttrace2_region_leave(\"fetch\", \"consume_refs\", the_repository);\n      \n      out:\n    @@ builtin/fetch.c: static int backfill_tags(struct display_state *display_state,\n      \t\t\t struct fetch_head *fetch_head,\n     -\t\t\t const struct fetch_config *config)\n     +\t\t\t const struct fetch_config *config,\n    -+\t\t\t struct strmap *delayed_ref_display)\n    ++\t\t\t struct ref_update_display_info **display_list,\n    ++\t\t\t size_t *display_count)\n      {\n      \tint retcode, cannot_reuse;\n      \n    @@ builtin/fetch.c: static int backfill_tags(struct display_state *display_state,\n      \ttransport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL);\n      \tretcode = fetch_and_consume_refs(display_state, transport, transaction, ref_map,\n     -\t\t\t\t\t fetch_head, config);\n    -+\t\t\t\t\t fetch_head, config, delayed_ref_display);\n    ++\t\t\t\t\t fetch_head, config, display_list, display_count);\n      \n      \tif (gsecondary) {\n      \t\ttransport_disconnect(gsecondary);\n    @@ builtin/fetch.c: struct ref_rejection_data {\n      \tbool conflict_msg_shown;\n      \tbool case_sensitive_msg_shown;\n      \tconst char *remote_name;\n    -+\tstruct strmap *delayed_ref_display;\n    ++\tstruct strmap *rejected_refs;\n      };\n      \n      static void ref_transaction_rejection_handler(const char *refname,\n    -@@ builtin/fetch.c: static void ref_transaction_rejection_handler(const char *refname,\n    - \t\t\t\t\t      void *cb_data)\n    - {\n    - \tstruct ref_rejection_data *data = cb_data;\n    -+\tstruct ref_update_display_info *info;\n    - \n    - \tif (err == REF_TRANSACTION_ERROR_CASE_CONFLICT && ignore_case &&\n    - \t    !data->case_sensitive_msg_shown) {\n     @@ builtin/fetch.c: static void ref_transaction_rejection_handler(const char *refname,\n      \t\t\t      refname, ref_transaction_error_msg(err));\n      \t}\n      \n    -+\tinfo = strmap_get(data->delayed_ref_display, refname);\n    -+\tif (info)\n    -+\t\tref_update_display_info_set_failed(info);\n    -+\n    ++\tstrmap_put(data->rejected_refs, refname, NULL);\n      \t*data->retcode = 1;\n      }\n      \n    @@ builtin/fetch.c: static void ref_transaction_rejection_handler(const char *refna\n       */\n      static int commit_ref_transaction(struct ref_transaction **transaction,\n      \t\t\t\t  bool is_atomic, const char *remote_name,\n    -+\t\t\t\t  struct strmap *delayed_ref_display,\n    ++\t\t\t\t  struct strmap *rejected_refs,\n      \t\t\t\t  struct strbuf *err)\n      {\n      \tint retcode = ref_transaction_commit(*transaction, err);\n    @@ builtin/fetch.c: static int commit_ref_transaction(struct ref_transaction **tran\n      \t\t\t.conflict_msg_shown = 0,\n      \t\t\t.remote_name = remote_name,\n      \t\t\t.retcode = &retcode,\n    -+\t\t\t.delayed_ref_display = delayed_ref_display,\n    ++\t\t\t.rejected_refs = rejected_refs,\n      \t\t};\n      \n      \t\tref_transaction_for_each_rejected_update(*transaction,\n    @@ builtin/fetch.c: static int do_fetch(struct transport *transport,\n      \tstruct fetch_head fetch_head = { 0 };\n      \tstruct strbuf err = STRBUF_INIT;\n      \tint do_set_head = 0;\n    -+\tstruct strmap delayed_ref_display = STRMAP_INIT;\n    ++\tstruct ref_update_display_info *display_list = NULL;\n    ++\tstruct strmap rejected_refs = STRMAP_INIT;\n    ++\tsize_t display_count = 0;\n     +\tint summary_width = 0;\n    -+\tstruct strmap_entry *e;\n    -+\tstruct hashmap_iter iter;\n      \n      \tif (tags == TAGS_DEFAULT) {\n      \t\tif (transport->remote->fetch_tags == 2)\n    @@ builtin/fetch.c: static int do_fetch(struct transport *transport,\n      \n      \tif (fetch_and_consume_refs(&display_state, transport, transaction, ref_map,\n     -\t\t\t\t   &fetch_head, config)) {\n    -+\t\t\t\t   &fetch_head, config, &delayed_ref_display)) {\n    ++\t\t\t\t   &fetch_head, config, &display_list, &display_count)) {\n      \t\tretcode = 1;\n      \t\tgoto cleanup;\n      \t}\n    @@ builtin/fetch.c: static int do_fetch(struct transport *transport,\n      \t\t\t */\n      \t\t\tif (backfill_tags(&display_state, transport, transaction, tags_ref_map,\n     -\t\t\t\t\t  &fetch_head, config))\n    -+\t\t\t\t\t  &fetch_head, config, &delayed_ref_display))\n    ++\t\t\t\t\t  &fetch_head, config, &display_list, &display_count))\n      \t\t\t\tretcode = 1;\n      \t\t}\n      \n    @@ builtin/fetch.c: static int do_fetch(struct transport *transport,\n      \tretcode = commit_ref_transaction(&transaction, atomic_fetch,\n     -\t\t\t\t\t transport->remote->name, &err);\n     +\t\t\t\t\t transport->remote->name,\n    -+\t\t\t\t\t &delayed_ref_display, &err);\n    ++\t\t\t\t\t &rejected_refs, &err);\n      \t/*\n      \t * With '--atomic', bail out if the transaction fails. Without '--atomic',\n      \t * continue to fetch head and perform other post-fetch operations.\n    @@ builtin/fetch.c: static int do_fetch(struct transport *transport,\n      \t\tcommit_ref_transaction(&transaction, false,\n     -\t\t\t\t       transport->remote->name, &err);\n     +\t\t\t\t       transport->remote->name,\n    -+\t\t\t\t       &delayed_ref_display, &err);\n    ++\t\t\t\t       &rejected_refs, &err);\n     +\n    -+\t/*\n    -+\t * Clear any pending information that needs to be shown to the user.\n    -+\t */\n    -+\tstrmap_for_each_entry(&delayed_ref_display, &iter, e) {\n    -+\t\tstruct ref_update_display_info *info = e->value;\n    -+\t\tref_update_display_info_display(info, &display_state, e->key, summary_width);\n    ++\tfor (size_t i = 0; i < display_count; i++) {\n    ++\t\tstruct ref_update_display_info *info = &display_list[i];\n    ++\n    ++\t\tif (!info->failed && strmap_contains(&rejected_refs, info->ref))\n    ++\t\t\tref_update_display_info_set_failed(info);\n    ++\t\tref_update_display_info_display(info, &display_state, summary_width);\n     +\t\tref_update_display_info_free(info);\n     +\t}\n      \n    @@ builtin/fetch.c: static int do_fetch(struct transport *transport,\n      \tif (transaction)\n      \t\tref_transaction_free(transaction);\n     +\n    -+\tstrmap_clear(&delayed_ref_display, 1);\n    ++\tfree(display_list);\n    ++\tstrmap_clear(&rejected_refs, 0);\n      \tdisplay_state_release(&display_state);\n      \tclose_fetch_head(&fetch_head);\n      \tstrbuf_release(&err);\n    @@ t/t5516-fetch-push.sh: test_expect_success 'pushing non-commit objects should re\n      \t\ttest_grep \"trying to write non-commit object $tagsha to branch ${SQ}refs/heads/branch${SQ}\" err\n      \t)\n      '\n    -\n    - ## t/t5574-fetch-output.sh ##\n    -@@ t/t5574-fetch-output.sh: test_expect_success 'fetch aligned output' '\n    - \t\tgrep -e \"->\" actual | cut -c 22- >../actual\n    - \t) &&\n    - \tcat >expect <<-\\EOF &&\n    --\tmain                 -> origin/main\n    - \tlooooooooooooong-tag -> looooooooooooong-tag\n    -+\tmain                 -> origin/main\n    - \tEOF\n    - \ttest_cmp expect actual\n    - '\n    -@@ t/t5574-fetch-output.sh: test_expect_success 'fetch compact output' '\n    - \t\tgrep -e \"->\" actual | cut -c 22- >../actual\n    - \t) &&\n    - \tcat >expect <<-\\EOF &&\n    --\tmain       -> origin/*\n    - \textraaa    -> *\n    -+\tmain       -> origin/*\n    - \tEOF\n    - \ttest_cmp expect actual\n    - '\n    -@@ t/t5574-fetch-output.sh: do\n    - \t\tcat >expect <<-EOF &&\n    - \t\t- $MAIN_OLD $ZERO_OID refs/forced/deleted-branch\n    - \t\t- $MAIN_OLD $ZERO_OID refs/unforced/deleted-branch\n    --\t\t  $MAIN_OLD $FAST_FORWARD_NEW refs/unforced/fast-forward\n    - \t\t! $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/unforced/force-updated\n    -+\t\t* $ZERO_OID $MAIN_OLD refs/forced/new-branch\n    -+\t\t* $ZERO_OID $MAIN_OLD refs/remotes/origin/new-branch\n    -+\t\t+ $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/remotes/origin/force-updated\n    -+\t\t  $MAIN_OLD $FAST_FORWARD_NEW refs/unforced/fast-forward\n    - \t\t* $ZERO_OID $MAIN_OLD refs/unforced/new-branch\n    - \t\t  $MAIN_OLD $FAST_FORWARD_NEW refs/forced/fast-forward\n    --\t\t+ $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/forced/force-updated\n    --\t\t* $ZERO_OID $MAIN_OLD refs/forced/new-branch\n    - \t\t  $MAIN_OLD $FAST_FORWARD_NEW refs/remotes/origin/fast-forward\n    --\t\t+ $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/remotes/origin/force-updated\n    --\t\t* $ZERO_OID $MAIN_OLD refs/remotes/origin/new-branch\n    -+\t\t+ $FORCE_UPDATED_OLD $FORCE_UPDATED_NEW refs/forced/force-updated\n    - \t\tEOF\n    - \n    - \t\t# Change the URL of the repository to fetch different references.\n    -@@ t/t5574-fetch-output.sh: test_expect_success 'fetch porcelain overrides fetch.output config' '\n    - \tnew_commit=$(git rev-parse HEAD) &&\n    - \n    - \tcat >expect <<-EOF &&\n    --\t  $old_commit $new_commit refs/remotes/origin/config-override\n    - \t* $ZERO_OID $new_commit refs/tags/new-commit\n    -+\t  $old_commit $new_commit refs/remotes/origin/config-override\n    - \tEOF\n    - \n    - \tgit -C porcelain -c fetch.output=compact fetch --porcelain >stdout 2>stderr &&\n\n\nbase-commit: 8745eae506f700657882b9e32b2aa00f234a6fb6\nchange-id: 20260113-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-17786b20894a\n\nThanks\n- Karthik\n\n"},{"id":"534221","messageId":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-2-e0edb29acbef@gmail.com","threadId":"64834","inReplyTo":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-0-e0edb29acbef@gmail.com","subject":"[PATCH v3 2/6] refs: add rejection detail to the callback function","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-01-20T09:59:20Z","receivedAt":"2026-01-20T09:59:39Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The previous commit started storing the rejection details alongside the\nerror code for rejected updates. Pass this along to the callback\nfunction `ref_transaction_for_each_rejected_update()`. Currently the\nfield is unused, but will be integrated in the upcoming commits.\n\nCo-authored-by: Jeff King <peff@peff.net>\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/fetch.c        | 1 +\n builtin/receive-pack.c | 1 +\n builtin/update-ref.c   | 1 +\n refs.c                 | 2 +-\n refs.h                 | 1 +\n 5 files changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 288d3772ea..d427adea61 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1649,6 +1649,7 @@ static void ref_transaction_rejection_handler(const char *refname,\n \t\t\t\t\t      const char *old_target UNUSED,\n \t\t\t\t\t      const char *new_target UNUSED,\n \t\t\t\t\t      enum ref_transaction_error err,\n+\t\t\t\t\t      const char *details UNUSED,\n \t\t\t\t\t      void *cb_data)\n {\n \tstruct ref_rejection_data *data = cb_data;\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex ef1f77be8c..94d3e73cee 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1813,6 +1813,7 @@ static void ref_transaction_rejection_handler(const char *refname,\n \t\t\t\t\t      const char *old_target UNUSED,\n \t\t\t\t\t      const char *new_target UNUSED,\n \t\t\t\t\t      enum ref_transaction_error err,\n+\t\t\t\t\t      const char *details UNUSED,\n \t\t\t\t\t      void *cb_data)\n {\n \tstruct strmap *failed_refs = cb_data;\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex 195437e7c6..0046a87c57 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -573,6 +573,7 @@ static void print_rejected_refs(const char *refname,\n \t\t\t\tconst char *old_target,\n \t\t\t\tconst char *new_target,\n \t\t\t\tenum ref_transaction_error err,\n+\t\t\t\tconst char *details UNUSED,\n \t\t\t\tvoid *cb_data UNUSED)\n {\n \tstruct strbuf sb = STRBUF_INIT;\ndiff --git a/refs.c b/refs.c\nindex 53919c3d22..c85c3d2c8b 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -2874,7 +2874,7 @@ void ref_transaction_for_each_rejected_update(struct ref_transaction *transactio\n \t\t   (update->flags & REF_HAVE_OLD) ? &update->old_oid : NULL,\n \t\t   (update->flags & REF_HAVE_NEW) ? &update->new_oid : NULL,\n \t\t   update->old_target, update->new_target,\n-\t\t   update->rejection_err, cb_data);\n+\t\t   update->rejection_err, update->rejection_details, cb_data);\n \t}\n }\n \ndiff --git a/refs.h b/refs.h\nindex d9051bbb04..4fbe3da924 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -975,6 +975,7 @@ typedef void ref_transaction_for_each_rejected_update_fn(const char *refname,\n \t\t\t\t\t\t\t const char *old_target,\n \t\t\t\t\t\t\t const char *new_target,\n \t\t\t\t\t\t\t enum ref_transaction_error err,\n+\t\t\t\t\t\t\t const char *details,\n \t\t\t\t\t\t\t void *cb_data);\n void ref_transaction_for_each_rejected_update(struct ref_transaction *transaction,\n \t\t\t\t\t      ref_transaction_for_each_rejected_update_fn cb,\n\n-- \n2.51.2\n\n"},{"id":"534222","messageId":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-3-e0edb29acbef@gmail.com","threadId":"64834","inReplyTo":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-0-e0edb29acbef@gmail.com","subject":"[PATCH v3 3/6] update-ref: utilize rejected error details if available","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-01-20T09:59:21Z","receivedAt":"2026-01-20T09:59:40Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"When git-update-ref(1) received the '--update-ref' flag, the error\ndetails generated in the refs namespace wasn't propagated with failed\nupdates. Instead only an error code pertaining to the type of rejection\nwas noted.\n\nThis missed detailed error message which the user can act upon. The\nprevious commits added the required code to propagate these detailed\nerror messages from the refs namespace. Now that additional details are\navailable, let's output this additional details to stderr. This allows\nusers to have additional information over the already present machine\nparsable output.\n\nWhile we're here, improve the existing tests for the machine parsable\noutput by checking for the entire output string and not just the\nrejection reason.\n\nReported-by: Elijah Newren <newren@gmail.com>\nCo-authored-by: Jeff King <peff@peff.net>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/update-ref.c  |  8 +++---\n t/t1400-update-ref.sh | 71 ++++++++++++++++++++++++++++++---------------------\n 2 files changed, 47 insertions(+), 32 deletions(-)\n\ndiff --git a/builtin/update-ref.c b/builtin/update-ref.c\nindex 0046a87c57..2d68c40ecb 100644\n--- a/builtin/update-ref.c\n+++ b/builtin/update-ref.c\n@@ -573,16 +573,18 @@ static void print_rejected_refs(const char *refname,\n \t\t\t\tconst char *old_target,\n \t\t\t\tconst char *new_target,\n \t\t\t\tenum ref_transaction_error err,\n-\t\t\t\tconst char *details UNUSED,\n+\t\t\t\tconst char *details,\n \t\t\t\tvoid *cb_data UNUSED)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n-\tconst char *reason = ref_transaction_error_msg(err);\n+\n+\tif (details && *details)\n+\t\terror(\"%s\", details);\n \n \tstrbuf_addf(&sb, \"rejected %s %s %s %s\\n\", refname,\n \t\t    new_oid ? oid_to_hex(new_oid) : new_target,\n \t\t    old_oid ? oid_to_hex(old_oid) : old_target,\n-\t\t    reason);\n+\t\t    ref_transaction_error_msg(err));\n \n \tfwrite(sb.buf, sb.len, 1, stdout);\n \tstrbuf_release(&sb);\ndiff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh\nindex db7f5444da..db6585b8d8 100755\n--- a/t/t1400-update-ref.sh\n+++ b/t/t1400-update-ref.sh\n@@ -2093,14 +2093,15 @@ do\n \n \t\t\tformat_command $type \"update refs/heads/ref1\" \"$old_head\" \"$head\" >stdin &&\n \t\t\tformat_command $type \"update refs/heads/ref2\" \"$(test_oid 001)\" \"$head\" >>stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/ref1 >actual &&\n \t\t\ttest_cmp expect actual &&\n \t\t\techo $head >expect &&\n \t\t\tgit rev-parse refs/heads/ref2 >actual &&\n \t\t\ttest_cmp expect actual &&\n-\t\t\ttest_grep -q \"invalid new value provided\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/ref2 $(test_oid 001) $head invalid new value provided\" stdout &&\n+\t\t\ttest_grep \"trying to write ref ${SQ}refs/heads/ref2${SQ} with nonexistent object\" err\n \t\t)\n \t'\n \n@@ -2119,14 +2120,15 @@ do\n \n \t\t\tformat_command $type \"update refs/heads/ref1\" \"$old_head\" \"$head\" >stdin &&\n \t\t\tformat_command $type \"update refs/heads/ref2\" \"$head_tree\" \"$head\" >>stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/ref1 >actual &&\n \t\t\ttest_cmp expect actual &&\n \t\t\techo $head >expect &&\n \t\t\tgit rev-parse refs/heads/ref2 >actual &&\n \t\t\ttest_cmp expect actual &&\n-\t\t\ttest_grep -q \"invalid new value provided\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/ref2 $head_tree $head invalid new value provided\" stdout &&\n+\t\t\ttest_grep \"trying to write non-commit object $head_tree to branch ${SQ}refs/heads/ref2${SQ}\" err\n \t\t)\n \t'\n \n@@ -2143,12 +2145,13 @@ do\n \n \t\t\tformat_command $type \"update refs/heads/ref1\" \"$old_head\" \"$head\" >stdin &&\n \t\t\tformat_command $type \"update refs/heads/ref2\" \"$old_head\" \"$head\" >>stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/ref1 >actual &&\n \t\t\ttest_cmp expect actual &&\n \t\t\ttest_must_fail git rev-parse refs/heads/ref2 &&\n-\t\t\ttest_grep -q \"reference does not exist\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/ref2 $old_head $head reference does not exist\" stdout &&\n+\t\t\ttest_grep \"cannot lock ref ${SQ}refs/heads/ref2${SQ}: unable to resolve reference ${SQ}refs/heads/ref2${SQ}\" err\n \t\t)\n \t'\n \n@@ -2166,13 +2169,14 @@ do\n \n \t\t\tformat_command $type \"update refs/heads/ref1\" \"$old_head\" \"$head\" >stdin &&\n \t\t\tformat_command $type \"update refs/heads/ref2\" \"$old_head\" \"$head\" >>stdin &&\n-\t\t\tgit update-ref $type --no-deref --stdin --batch-updates <stdin >stdout &&\n+\t\t\tgit update-ref $type --no-deref --stdin --batch-updates <stdin >stdout 2>err &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/ref1 >actual &&\n \t\t\ttest_cmp expect actual &&\n \t\t\techo $head >expect &&\n \t\t\ttest_must_fail git rev-parse refs/heads/ref2 &&\n-\t\t\ttest_grep -q \"reference does not exist\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/ref2 $old_head $head reference does not exist\" stdout &&\n+\t\t\ttest_grep \"cannot lock ref ${SQ}refs/heads/ref2${SQ}: reference is missing but expected $head\" err\n \t\t)\n \t'\n \n@@ -2190,7 +2194,7 @@ do\n \n \t\t\tformat_command $type \"update refs/heads/ref1\" \"$old_head\" \"$head\" >stdin &&\n \t\t\tformat_command $type \"symref-update refs/heads/ref2\" \"$old_head\" \"ref\" \"refs/heads/nonexistent\" >>stdin &&\n-\t\t\tgit update-ref $type --no-deref --stdin --batch-updates <stdin >stdout &&\n+\t\t\tgit update-ref $type --no-deref --stdin --batch-updates <stdin >stdout 2>err &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/ref1 >actual &&\n \t\t\ttest_cmp expect actual &&\n@@ -2198,7 +2202,8 @@ do\n \t\t\techo $head >expect &&\n \t\t\tgit rev-parse refs/heads/ref2 >actual &&\n \t\t\ttest_cmp expect actual &&\n-\t\t\ttest_grep -q \"expected symref but found regular ref\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/ref2 $ZERO_OID $ZERO_OID expected symref but found regular ref\" stdout &&\n+\t\t\ttest_grep \"cannot lock ref ${SQ}refs/heads/ref2${SQ}: expected symref with target ${SQ}refs/heads/nonexistent${SQ}: but is a regular ref\" err\n \t\t)\n \t'\n \n@@ -2216,14 +2221,15 @@ do\n \n \t\t\tformat_command $type \"update refs/heads/ref1\" \"$old_head\" \"$head\" >stdin &&\n \t\t\tformat_command $type \"update refs/heads/ref2\" \"$old_head\" \"$Z\" >>stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/ref1 >actual &&\n \t\t\ttest_cmp expect actual &&\n \t\t\techo $head >expect &&\n \t\t\tgit rev-parse refs/heads/ref2 >actual &&\n \t\t\ttest_cmp expect actual &&\n-\t\t\ttest_grep -q \"reference already exists\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/ref2 $old_head $ZERO_OID reference already exists\" stdout &&\n+\t\t\ttest_grep \"cannot lock ref ${SQ}refs/heads/ref2${SQ}: reference already exists\" err\n \t\t)\n \t'\n \n@@ -2241,14 +2247,15 @@ do\n \n \t\t\tformat_command $type \"update refs/heads/ref1\" \"$old_head\" \"$head\" >stdin &&\n \t\t\tformat_command $type \"update refs/heads/ref2\" \"$head\" \"$old_head\" >>stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/ref1 >actual &&\n \t\t\ttest_cmp expect actual &&\n \t\t\techo $head >expect &&\n \t\t\tgit rev-parse refs/heads/ref2 >actual &&\n \t\t\ttest_cmp expect actual &&\n-\t\t\ttest_grep -q \"incorrect old value provided\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/ref2 $head $old_head incorrect old value provided\" stdout &&\n+\t\t\ttest_grep \"cannot lock ref ${SQ}refs/heads/ref2${SQ}: is at $head but expected $old_head\" err\n \t\t)\n \t'\n \n@@ -2264,12 +2271,13 @@ do\n \t\t\tgit update-ref refs/heads/ref/foo $head &&\n \n \t\t\tformat_command $type \"update refs/heads/ref/foo\" \"$old_head\" \"$head\" >stdin &&\n-\t\t\tformat_command $type \"update refs/heads/ref\" \"$old_head\" \"\" >>stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n+\t\t\tformat_command $type \"update refs/heads/ref\" \"$old_head\" \"$ZERO_OID\" >>stdin &&\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/ref/foo >actual &&\n \t\t\ttest_cmp expect actual &&\n-\t\t\ttest_grep -q \"refname conflict\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/ref $old_head $ZERO_OID refname conflict\" stdout &&\n+\t\t\ttest_grep \"${SQ}refs/heads/ref/foo${SQ} exists; cannot create ${SQ}refs/heads/ref${SQ}\" err\n \t\t)\n \t'\n \n@@ -2284,13 +2292,14 @@ do\n \t\t\thead=$(git rev-parse HEAD) &&\n \t\t\tgit update-ref refs/heads/ref/foo $head &&\n \n-\t\t\tformat_command $type \"update refs/heads/foo\" \"$old_head\" \"\" >stdin &&\n-\t\t\tformat_command $type \"update refs/heads/ref\" \"$old_head\" \"\" >>stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n+\t\t\tformat_command $type \"update refs/heads/foo\" \"$old_head\" \"$ZERO_OID\" >stdin &&\n+\t\t\tformat_command $type \"update refs/heads/ref\" \"$old_head\" \"$ZERO_OID\" >>stdin &&\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/foo >actual &&\n \t\t\ttest_cmp expect actual &&\n-\t\t\ttest_grep -q \"refname conflict\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/ref $old_head $ZERO_OID refname conflict\" stdout &&\n+\t\t\ttest_grep \"${SQ}refs/heads/ref/foo${SQ} exists; cannot create ${SQ}refs/heads/ref${SQ}\" err\n \t\t)\n \t'\n \n@@ -2309,14 +2318,15 @@ do\n \t\t\t\tformat_command $type \"create refs/heads/ref\" \"$old_head\" &&\n \t\t\t\tformat_command $type \"create refs/heads/Foo\" \"$old_head\"\n \t\t\t} >stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n \n \t\t\techo $head >expect &&\n \t\t\tgit rev-parse refs/heads/foo >actual &&\n \t\t\techo $old_head >expect &&\n \t\t\tgit rev-parse refs/heads/ref >actual &&\n \t\t\ttest_cmp expect actual &&\n-\t\t\ttest_grep -q \"reference conflict due to case-insensitive filesystem\" stdout\n+\t\t\ttest_grep \"rejected refs/heads/Foo $old_head $ZERO_OID reference conflict due to case-insensitive filesystem\" stdout &&\n+\t\t\ttest_grep -e \"cannot lock ref ${SQ}refs/heads/Foo${SQ}: Unable to create\" -e \"Foo.lock\" err\n \t\t)\n \t'\n \n@@ -2357,8 +2367,9 @@ do\n \t\t\tgit symbolic-ref refs/heads/symbolic refs/heads/non-existent &&\n \n \t\t\tformat_command $type \"delete refs/heads/symbolic\" \"$head\" >stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n-\t\t\ttest_grep \"reference does not exist\" stdout\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n+\t\t\ttest_grep \"rejected refs/heads/non-existent $ZERO_OID $head reference does not exist\" stdout &&\n+\t\t\ttest_grep \"cannot lock ref ${SQ}refs/heads/symbolic${SQ}: unable to resolve reference ${SQ}refs/heads/non-existent${SQ}\" err\n \t\t)\n \t'\n \n@@ -2373,8 +2384,9 @@ do\n \t\t\thead=$(git rev-parse HEAD) &&\n \n \t\t\tformat_command $type \"delete refs/heads/new-branch\" \"$head\" >stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n-\t\t\ttest_grep \"incorrect old value provided\" stdout\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n+\t\t\ttest_grep \"rejected refs/heads/new-branch $ZERO_OID $head incorrect old value provided\" stdout &&\n+\t\t\ttest_grep \"cannot lock ref ${SQ}refs/heads/new-branch${SQ}: is at $(git rev-parse new-branch) but expected $head\" err\n \t\t)\n \t'\n \n@@ -2387,8 +2399,9 @@ do\n \t\t\thead=$(git rev-parse HEAD) &&\n \n \t\t\tformat_command $type \"delete refs/heads/non-existent\" \"$head\" >stdin &&\n-\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout &&\n-\t\t\ttest_grep \"reference does not exist\" stdout\n+\t\t\tgit update-ref $type --stdin --batch-updates <stdin >stdout 2>err &&\n+\t\t\ttest_grep \"rejected refs/heads/non-existent $ZERO_OID $head reference does not exist\" stdout &&\n+\t\t\ttest_grep \"cannot lock ref ${SQ}refs/heads/non-existent${SQ}: unable to resolve reference ${SQ}refs/heads/non-existent${SQ}\" err\n \t\t)\n \t'\n done\n\n-- \n2.51.2\n\n"},{"id":"534223","messageId":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-4-e0edb29acbef@gmail.com","threadId":"64834","inReplyTo":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-0-e0edb29acbef@gmail.com","subject":"[PATCH v3 4/6] fetch: utilize rejected ref error details","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-01-20T09:59:22Z","receivedAt":"2026-01-20T09:59:41Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In 0e358de64a (fetch: use batched reference updates, 2025-05-19),\ngit-fetch(1) switched to using batched reference updates. This also\nintroduced a regression wherein instead of providing detailed error\nmessages for failed referenced updates, the users were provided generic\nerror messages based on the error type.\n\nSimilar to the previous commit, switch to using detailed error messages\nif present for failed reference updates to fix this regression.\n\nReported-by: Elijah Newren <newren@gmail.com>\nCo-authored-by: Jeff King <peff@peff.net>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/fetch.c  | 10 ++++++----\n t/t5510-fetch.sh |  8 ++++----\n 2 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex d427adea61..49495be0b6 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -1649,7 +1649,7 @@ static void ref_transaction_rejection_handler(const char *refname,\n \t\t\t\t\t      const char *old_target UNUSED,\n \t\t\t\t\t      const char *new_target UNUSED,\n \t\t\t\t\t      enum ref_transaction_error err,\n-\t\t\t\t\t      const char *details UNUSED,\n+\t\t\t\t\t      const char *details,\n \t\t\t\t\t      void *cb_data)\n {\n \tstruct ref_rejection_data *data = cb_data;\n@@ -1674,9 +1674,11 @@ static void ref_transaction_rejection_handler(const char *refname,\n \t\t\t\"branches\"), data->remote_name);\n \t\tdata->conflict_msg_shown = true;\n \t} else {\n-\t\tconst char *reason = ref_transaction_error_msg(err);\n-\n-\t\terror(_(\"fetching ref %s failed: %s\"), refname, reason);\n+\t\tif (details)\n+\t\t\terror(\"%s\", details);\n+\t\telse\n+\t\t\terror(_(\"fetching ref %s failed: %s\"),\n+\t\t\t      refname, ref_transaction_error_msg(err));\n \t}\n \n \t*data->retcode = 1;\ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex ce1c23684e..c69afb5a60 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -1516,7 +1516,7 @@ test_expect_success REFFILES 'existing reference lock in repo' '\n \t\tgit remote add origin ../base &&\n \t\ttouch refs/heads/foo.lock &&\n \t\ttest_must_fail git fetch -f origin \"refs/heads/*:refs/heads/*\" 2>err &&\n-\t\ttest_grep \"error: fetching ref refs/heads/foo failed: reference already exists\" err &&\n+\t\ttest_grep -e \"error: cannot lock ref ${SQ}refs/heads/foo${SQ}: Unable to create\" -e \"refs/heads/foo.lock${SQ}: File exists.\" err &&\n \t\tgit rev-parse refs/heads/main >expect &&\n \t\tgit rev-parse refs/heads/branch >actual &&\n \t\ttest_cmp expect actual\n@@ -1530,7 +1530,7 @@ test_expect_success CASE_INSENSITIVE_FS,REFFILES 'F/D conflict on case insensiti\n \t\tcd case_insensitive &&\n \t\tgit remote add origin -- ../case_sensitive_fd &&\n \t\ttest_must_fail git fetch -f origin \"refs/heads/*:refs/heads/*\" 2>err &&\n-\t\ttest_grep \"failed: refname conflict\" err &&\n+\t\ttest_grep \"cannot process ${SQ}refs/remotes/origin/foo${SQ} and ${SQ}refs/remotes/origin/foo/bar${SQ} at the same time\" err &&\n \t\tgit rev-parse refs/heads/main >expect &&\n \t\tgit rev-parse refs/heads/foo/bar >actual &&\n \t\ttest_cmp expect actual\n@@ -1544,7 +1544,7 @@ test_expect_success CASE_INSENSITIVE_FS,REFFILES 'D/F conflict on case insensiti\n \t\tcd case_insensitive &&\n \t\tgit remote add origin -- ../case_sensitive_df &&\n \t\ttest_must_fail git fetch -f origin \"refs/heads/*:refs/heads/*\" 2>err &&\n-\t\ttest_grep \"failed: refname conflict\" err &&\n+\t\ttest_grep \"cannot lock ref ${SQ}refs/remotes/origin/foo${SQ}: there is a non-empty directory ${SQ}./refs/remotes/origin/foo${SQ} blocking reference ${SQ}refs/remotes/origin/foo${SQ}\" err &&\n \t\tgit rev-parse refs/heads/main >expect &&\n \t\tgit rev-parse refs/heads/Foo/bar >actual &&\n \t\ttest_cmp expect actual\n@@ -1658,7 +1658,7 @@ test_expect_success REFFILES \"FETCH_HEAD is updated even if ref updates fail\" '\n \t\tgit remote add origin ../base &&\n \t\t>refs/heads/foo.lock &&\n \t\ttest_must_fail git fetch -f origin \"refs/heads/*:refs/heads/*\" 2>err &&\n-\t\ttest_grep \"error: fetching ref refs/heads/foo failed: reference already exists\" err &&\n+\t\ttest_grep -e \"error: cannot lock ref ${SQ}refs/heads/foo${SQ}: Unable to create\" -e \"refs/heads/foo.lock${SQ}: File exists.\" err &&\n \t\ttest_grep \"branch ${SQ}branch${SQ} of ../base\" FETCH_HEAD &&\n \t\ttest_grep \"branch ${SQ}foo${SQ} of ../base\" FETCH_HEAD\n \t)\n\n-- \n2.51.2\n\n"},{"id":"534224","messageId":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-5-e0edb29acbef@gmail.com","threadId":"64834","inReplyTo":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-0-e0edb29acbef@gmail.com","subject":"[PATCH v3 5/6] receive-pack: utilize rejected ref error details","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-01-20T09:59:23Z","receivedAt":"2026-01-20T09:59:42Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In 9d2962a7c4 (receive-pack: use batched reference updates, 2025-05-19),\ngit-receive-pack(1) switched to using batched reference updates. This also\nintroduced a regression wherein instead of providing detailed error\nmessages for failed referenced updates, the users were provided generic\nerror messages based on the error type.\n\nNow that the updates also contain detailed error message, propagate\nthose to the client via 'rp_error'. The detailed error messages can be\nvery verbose, for e.g. in the files backend, when trying to write a\nnon-commit object to a branch, you would see:\n\n   ! [remote rejected] 3eaec9ccf3a53f168362a6b3fdeb73426fb9813d ->\n   branch (cannot update ref 'refs/heads/branch': trying to write\n   non-commit object 3eaec9ccf3a53f168362a6b3fdeb73426fb9813d to branch\n   'refs/heads/branch')\n\nHere the refname is repeated multiple times due to how error messages\nare propagated and filled over the code stack. This potentially can be\ncleaned up in a future commit.\n\nReported-by: Elijah Newren <newren@gmail.com>\nCo-authored-by: Jeff King <peff@peff.net>\nSigned-off-by: Jeff King <peff@peff.net>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/receive-pack.c |  8 ++++++--\n t/t5516-fetch-push.sh  | 15 +++++++++++++++\n 2 files changed, 21 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 94d3e73cee..70e04b3efb 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1813,11 +1813,14 @@ static void ref_transaction_rejection_handler(const char *refname,\n \t\t\t\t\t      const char *old_target UNUSED,\n \t\t\t\t\t      const char *new_target UNUSED,\n \t\t\t\t\t      enum ref_transaction_error err,\n-\t\t\t\t\t      const char *details UNUSED,\n+\t\t\t\t\t      const char *details,\n \t\t\t\t\t      void *cb_data)\n {\n \tstruct strmap *failed_refs = cb_data;\n \n+\tif (details)\n+\t\trp_error(\"%s\", details);\n+\n \tstrmap_put(failed_refs, refname, (char *)ref_transaction_error_msg(err));\n }\n \n@@ -1884,6 +1887,7 @@ static void execute_commands_non_atomic(struct command *commands,\n \t\t}\n \n \t\tref_transaction_for_each_rejected_update(transaction,\n+\n \t\t\t\t\t\t\t ref_transaction_rejection_handler,\n \t\t\t\t\t\t\t &failed_refs);\n \n@@ -1895,7 +1899,7 @@ static void execute_commands_non_atomic(struct command *commands,\n \t\t\tif (reported_error)\n \t\t\t\tcmd->error_string = reported_error;\n \t\t\telse if (strmap_contains(&failed_refs, cmd->ref_name))\n-\t\t\t\tcmd->error_string = strmap_get(&failed_refs, cmd->ref_name);\n+\t\t\t\tcmd->error_string = cmd->error_string_owned = xstrdup(strmap_get(&failed_refs, cmd->ref_name));\n \t\t}\n \n \tcleanup:\ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex 46926e7bbd..45595991c8 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -1882,4 +1882,19 @@ test_expect_success 'push with F/D conflict with deletion and creation' '\n \tgit push testrepo :refs/heads/branch/conflict refs/heads/branch\n '\n \n+test_expect_success 'pushing non-commit objects should report error' '\n+\ttest_when_finished \"rm -rf dest repo\" &&\n+\tgit init dest &&\n+\tgit init repo &&\n+\n+\t(\n+\t\tcd repo &&\n+\t\ttest_commit --annotate test &&\n+\n+\t\ttagsha=$(git rev-parse test^{tag}) &&\n+\t\ttest_must_fail git push ../dest \"$tagsha:refs/heads/branch\" 2>err &&\n+\t\ttest_grep \"trying to write non-commit object $tagsha to branch ${SQ}refs/heads/branch${SQ}\" err\n+\t)\n+'\n+\n test_done\n\n-- \n2.51.2\n\n"},{"id":"534225","messageId":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-6-e0edb29acbef@gmail.com","threadId":"64834","inReplyTo":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-0-e0edb29acbef@gmail.com","subject":"[PATCH v3 6/6] fetch: delay user information post committing of transaction","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-01-20T09:59:24Z","receivedAt":"2026-01-20T09:59:43Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In Git 2.50 and earlier, we would display failure codes and error\nmessage as part of the status display:\n\n  $ git fetch . v1.0.0:refs/heads/foo\n    error: cannot update ref 'refs/heads/foo': trying to write non-commit object f665776185ad074b236c00751d666da7d1977dbe to branch 'refs/heads/foo'\n    From .\n     ! [new tag]               v1.0.0     -> foo  (unable to update local ref)\n\nWith the addition of batched updates, this information is no longer\nshown to the user:\n\n  $ git fetch . v1.0.0:refs/heads/foo\n    From .\n     * [new tag]               v1.0.0     -> foo\n    error: cannot update ref 'refs/heads/foo': trying to write non-commit object f665776185ad074b236c00751d666da7d1977dbe to branch 'refs/heads/foo'\n\nSince reference updates are batched and processed together at the end,\ninformation around the outcome is not available during individual\nreference parsing.\n\nTo overcome this, collate and delay the output to the end. Introduce\n`ref_update_display_info` which will hold individual update's\ninformation and also whether the update failed or succeeded. This\nfinally allows us to iterate over all such updates and print them to the\nuser.\n\nUsing an dynamic array and strmap does add some overhead to\n'git-fetch(1)', but from benchmarking this seems to be not too bad:\n\n  Benchmark 1: fetch: many refs (refformat = files, refcount = 1000, revision = master)\n    Time (mean ± σ):      42.6 ms ±   1.2 ms    [User: 13.1 ms, System: 29.8 ms]\n    Range (min … max):    40.1 ms …  45.8 ms    47 runs\n\n  Benchmark 2: fetch: many refs (refformat = files, refcount = 1000, revision = HEAD)\n    Time (mean ± σ):      43.1 ms ±   1.2 ms    [User: 12.7 ms, System: 30.7 ms]\n    Range (min … max):    40.5 ms …  45.8 ms    48 runs\n\n  Summary\n    fetch: many refs (refformat = files, refcount = 1000, revision = master) ran\n      1.01 ± 0.04 times faster than fetch: many refs (refformat = files, refcount = 1000, revision = HEAD)\n\nAnother approach would be to move the status printing logic to be\nhandled post the transaction being committed. That however would require\nadding an iterator to the ref transaction that tracks both the outcome\n(success/failure) and the original refspec information for each update,\nwhich is more involved infrastructure work compared to the strmap\napproach here.\n\nHelped-by: Phillip Wood <phillip.wood123@gmail.com>\nReported-by: Jeff King <peff@peff.net>\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n builtin/fetch.c       | 250 +++++++++++++++++++++++++++++++++++++++-----------\n t/t5516-fetch-push.sh |   1 +\n 2 files changed, 197 insertions(+), 54 deletions(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 49495be0b6..3a3f1d8914 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -861,12 +861,87 @@ static void display_ref_update(struct display_state *display_state, char code,\n \tfputs(display_state->buf.buf, f);\n }\n \n+struct ref_update_display_info {\n+\tbool failed;\n+\tchar success_code;\n+\tchar fail_code;\n+\tconst char *summary;\n+\tconst char *fail_detail;\n+\tconst char *success_detail;\n+\tconst char *ref;\n+\tconst char *remote;\n+\tstruct object_id old_oid;\n+\tstruct object_id new_oid;\n+};\n+\n+static struct ref_update_display_info *ref_update_display_info_append(\n+\t\t\t\t\t   struct ref_update_display_info **list,\n+\t\t\t\t\t   size_t *count,\n+\t\t\t\t\t   char success_code,\n+\t\t\t\t\t   char fail_code,\n+\t\t\t\t\t   const char *summary,\n+\t\t\t\t\t   const char *success_detail,\n+\t\t\t\t\t   const char *fail_detail,\n+\t\t\t\t\t   const char *ref,\n+\t\t\t\t\t   const char *remote,\n+\t\t\t\t\t   const struct object_id *old_oid,\n+\t\t\t\t\t   const struct object_id *new_oid)\n+{\n+\tstruct ref_update_display_info *info;\n+\tsize_t index = *count;\n+\n+\t(*count)++;\n+\tREALLOC_ARRAY(*list, *count);\n+\n+\tinfo = &(*list)[index];\n+\n+\tinfo->failed = false;\n+\tinfo->success_code = success_code;\n+\tinfo->fail_code = fail_code;\n+\tinfo->summary = xstrdup(summary);\n+\tinfo->success_detail = xstrdup_or_null(success_detail);\n+\tinfo->fail_detail = xstrdup_or_null(fail_detail);\n+\tinfo->remote = xstrdup(remote);\n+\tinfo->ref = xstrdup(ref);\n+\n+\toidcpy(&info->old_oid, old_oid);\n+\toidcpy(&info->new_oid, new_oid);\n+\n+\treturn info;\n+}\n+\n+static void ref_update_display_info_set_failed(struct ref_update_display_info *info)\n+{\n+\tinfo->failed = true;\n+}\n+\n+static void ref_update_display_info_free(struct ref_update_display_info *info)\n+{\n+\tfree((char *)info->summary);\n+\tfree((char *)info->success_detail);\n+\tfree((char *)info->fail_detail);\n+\tfree((char *)info->remote);\n+\tfree((char *)info->ref);\n+}\n+\n+static void ref_update_display_info_display(struct ref_update_display_info *info,\n+\t\t\t\t\t    struct display_state *display_state,\n+\t\t\t\t\t    int summary_width)\n+{\n+\tdisplay_ref_update(display_state,\n+\t\t\t   info->failed ? info->fail_code : info->success_code,\n+\t\t\t   info->summary,\n+\t\t\t   info->failed ? info->fail_detail : info->success_detail,\n+\t\t\t   info->remote, info->ref, &info->old_oid,\n+\t\t\t   &info->new_oid, summary_width);\n+}\n+\n static int update_local_ref(struct ref *ref,\n \t\t\t    struct ref_transaction *transaction,\n-\t\t\t    struct display_state *display_state,\n \t\t\t    const struct ref *remote_ref,\n-\t\t\t    int summary_width,\n-\t\t\t    const struct fetch_config *config)\n+\t\t\t    const struct fetch_config *config,\n+\t\t\t    struct ref_update_display_info **display_list,\n+\t\t\t    size_t *display_count)\n {\n \tstruct commit *current = NULL, *updated;\n \tint fast_forward = 0;\n@@ -877,41 +952,56 @@ static int update_local_ref(struct ref *ref,\n \n \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n \t\tif (verbosity > 0)\n-\t\t\tdisplay_ref_update(display_state, '=', _(\"[up to date]\"), NULL,\n-\t\t\t\t\t   remote_ref->name, ref->name,\n-\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n+\t\t\tref_update_display_info_append(display_list, display_count,\n+\t\t\t\t\t\t       '=', '=', _(\"[up to date]\"),\n+\t\t\t\t\t\t       NULL, NULL, ref->name,\n+\t\t\t\t\t\t       remote_ref->name, &ref->old_oid,\n+\t\t\t\t\t\t       &ref->new_oid);\n \t\treturn 0;\n \t}\n \n \tif (!update_head_ok &&\n \t    !is_null_oid(&ref->old_oid) &&\n \t    branch_checked_out(ref->name)) {\n+\t\tstruct ref_update_display_info *info;\n \t\t/*\n \t\t * If this is the head, and it's not okay to update\n \t\t * the head, and the old value of the head isn't empty...\n \t\t */\n-\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"),\n-\t\t\t\t   _(\"can't fetch into checked-out branch\"),\n-\t\t\t\t   remote_ref->name, ref->name,\n-\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n+\t\tinfo = ref_update_display_info_append(display_list, display_count,\n+\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"),\n+\t\t\t\t\t\t      NULL, _(\"can't fetch into checked-out branch\"),\n+\t\t\t\t\t\t      ref->name, remote_ref->name,\n+\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n+\t\tref_update_display_info_set_failed(info);\n \t\treturn 1;\n \t}\n \n \tif (!is_null_oid(&ref->old_oid) &&\n \t    starts_with(ref->name, \"refs/tags/\")) {\n+\t\tstruct ref_update_display_info *info;\n+\n \t\tif (force || ref->force) {\n \t\t\tint r;\n+\n \t\t\tr = s_update_ref(\"updating tag\", ref, transaction, 0);\n-\t\t\tdisplay_ref_update(display_state, r ? '!' : 't', _(\"[tag update]\"),\n-\t\t\t\t\t   r ? _(\"unable to update local ref\") : NULL,\n-\t\t\t\t\t   remote_ref->name, ref->name,\n-\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n+\n+\t\t\tinfo = ref_update_display_info_append(display_list, display_count,\n+\t\t\t\t\t\t\t      't', '!', _(\"[tag update]\"), NULL,\n+\t\t\t\t\t\t\t      _(\"unable to update local ref\"),\n+\t\t\t\t\t\t\t      ref->name, remote_ref->name,\n+\t\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n+\t\t\tif (r)\n+\t\t\t\tref_update_display_info_set_failed(info);\n+\n \t\t\treturn r;\n \t\t} else {\n-\t\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"),\n-\t\t\t\t\t   _(\"would clobber existing tag\"),\n-\t\t\t\t\t   remote_ref->name, ref->name,\n-\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n+\t\t\tinfo = ref_update_display_info_append(display_list, display_count,\n+\t\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"), NULL,\n+\t\t\t\t\t\t\t      _(\"would clobber existing tag\"),\n+\t\t\t\t\t\t\t      ref->name, remote_ref->name,\n+\t\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n+\t\t\tref_update_display_info_set_failed(info);\n \t\t\treturn 1;\n \t\t}\n \t}\n@@ -921,6 +1011,7 @@ static int update_local_ref(struct ref *ref,\n \tupdated = lookup_commit_reference_gently(the_repository,\n \t\t\t\t\t\t &ref->new_oid, 1);\n \tif (!current || !updated) {\n+\t\tstruct ref_update_display_info *info;\n \t\tconst char *msg;\n \t\tconst char *what;\n \t\tint r;\n@@ -941,10 +1032,15 @@ static int update_local_ref(struct ref *ref,\n \t\t}\n \n \t\tr = s_update_ref(msg, ref, transaction, 0);\n-\t\tdisplay_ref_update(display_state, r ? '!' : '*', what,\n-\t\t\t\t   r ? _(\"unable to update local ref\") : NULL,\n-\t\t\t\t   remote_ref->name, ref->name,\n-\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n+\n+\t\tinfo = ref_update_display_info_append(display_list, display_count,\n+\t\t\t\t\t\t      '*', '!', what, NULL,\n+\t\t\t\t\t\t      _(\"unable to update local ref\"),\n+\t\t\t\t\t\t      ref->name, remote_ref->name,\n+\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n+\t\tif (r)\n+\t\t\tref_update_display_info_set_failed(info);\n+\n \t\treturn r;\n \t}\n \n@@ -960,6 +1056,7 @@ static int update_local_ref(struct ref *ref,\n \t}\n \n \tif (fast_forward) {\n+\t\tstruct ref_update_display_info *info;\n \t\tstruct strbuf quickref = STRBUF_INIT;\n \t\tint r;\n \n@@ -967,29 +1064,46 @@ static int update_local_ref(struct ref *ref,\n \t\tstrbuf_addstr(&quickref, \"..\");\n \t\tstrbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);\n \t\tr = s_update_ref(\"fast-forward\", ref, transaction, 1);\n-\t\tdisplay_ref_update(display_state, r ? '!' : ' ', quickref.buf,\n-\t\t\t\t   r ? _(\"unable to update local ref\") : NULL,\n-\t\t\t\t   remote_ref->name, ref->name,\n-\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n+\n+\t\tinfo = ref_update_display_info_append(display_list, display_count,\n+\t\t\t\t\t\t      ' ', '!', quickref.buf, NULL,\n+\t\t\t\t\t\t      _(\"unable to update local ref\"),\n+\t\t\t\t\t\t      ref->name, remote_ref->name,\n+\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n+\t\tif (r)\n+\t\t\tref_update_display_info_set_failed(info);\n+\n \t\tstrbuf_release(&quickref);\n \t\treturn r;\n \t} else if (force || ref->force) {\n+\t\tstruct ref_update_display_info *info;\n \t\tstruct strbuf quickref = STRBUF_INIT;\n \t\tint r;\n+\n \t\tstrbuf_add_unique_abbrev(&quickref, &current->object.oid, DEFAULT_ABBREV);\n \t\tstrbuf_addstr(&quickref, \"...\");\n \t\tstrbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);\n \t\tr = s_update_ref(\"forced-update\", ref, transaction, 1);\n-\t\tdisplay_ref_update(display_state, r ? '!' : '+', quickref.buf,\n-\t\t\t\t   r ? _(\"unable to update local ref\") : _(\"forced update\"),\n-\t\t\t\t   remote_ref->name, ref->name,\n-\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n+\n+\t\tinfo = ref_update_display_info_append(display_list, display_count,\n+\t\t\t\t\t\t      '+', '!', quickref.buf, _(\"forced update\"),\n+\t\t\t\t\t\t      _(\"unable to update local ref\"),\n+\t\t\t\t\t\t      ref->name, remote_ref->name,\n+\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n+\n+\t\tif (r)\n+\t\t\tref_update_display_info_set_failed(info);\n+\n \t\tstrbuf_release(&quickref);\n \t\treturn r;\n \t} else {\n-\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"), _(\"non-fast-forward\"),\n-\t\t\t\t   remote_ref->name, ref->name,\n-\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n+\t\tstruct ref_update_display_info *info;\n+\t\tinfo = ref_update_display_info_append(display_list, display_count,\n+\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"), NULL,\n+\t\t\t\t\t\t      _(\"non-fast-forward\"),\n+\t\t\t\t\t\t      ref->name, remote_ref->name,\n+\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n+\t\tref_update_display_info_set_failed(info);\n \t\treturn 1;\n \t}\n }\n@@ -1103,17 +1217,15 @@ static int store_updated_refs(struct display_state *display_state,\n \t\t\t      int connectivity_checked,\n \t\t\t      struct ref_transaction *transaction, struct ref *ref_map,\n \t\t\t      struct fetch_head *fetch_head,\n-\t\t\t      const struct fetch_config *config)\n+\t\t\t      const struct fetch_config *config,\n+\t\t\t      struct ref_update_display_info **display_list,\n+\t\t\t      size_t *display_count)\n {\n \tint rc = 0;\n \tstruct strbuf note = STRBUF_INIT;\n \tconst char *what, *kind;\n \tstruct ref *rm;\n \tint want_status;\n-\tint summary_width = 0;\n-\n-\tif (verbosity >= 0)\n-\t\tsummary_width = transport_summary_width(ref_map);\n \n \tif (!connectivity_checked) {\n \t\tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n@@ -1218,8 +1330,9 @@ static int store_updated_refs(struct display_state *display_state,\n \t\t\t\t\t  display_state->url_len);\n \n \t\t\tif (ref) {\n-\t\t\t\trc |= update_local_ref(ref, transaction, display_state,\n-\t\t\t\t\t\t       rm, summary_width, config);\n+\t\t\t\trc |= update_local_ref(ref, transaction, rm,\n+\t\t\t\t\t\t       config, display_list,\n+\t\t\t\t\t\t       display_count);\n \t\t\t\tfree(ref);\n \t\t\t} else if (write_fetch_head || dry_run) {\n \t\t\t\t/*\n@@ -1227,12 +1340,11 @@ static int store_updated_refs(struct display_state *display_state,\n \t\t\t\t * would be written to FETCH_HEAD, if --dry-run\n \t\t\t\t * is set).\n \t\t\t\t */\n-\t\t\t\tdisplay_ref_update(display_state, '*',\n-\t\t\t\t\t\t   *kind ? kind : \"branch\", NULL,\n-\t\t\t\t\t\t   rm->name,\n-\t\t\t\t\t\t   \"FETCH_HEAD\",\n-\t\t\t\t\t\t   &rm->new_oid, &rm->old_oid,\n-\t\t\t\t\t\t   summary_width);\n+\n+\t\t\t\tref_update_display_info_append(display_list, display_count,\n+\t\t\t\t\t\t\t       '*', '*', *kind ? kind : \"branch\",\n+\t\t\t\t\t\t\t       NULL, NULL, \"FETCH_HEAD\", rm->name,\n+\t\t\t\t\t\t\t       &rm->new_oid, &rm->old_oid);\n \t\t\t}\n \t\t}\n \t}\n@@ -1300,7 +1412,9 @@ static int fetch_and_consume_refs(struct display_state *display_state,\n \t\t\t\t  struct ref_transaction *transaction,\n \t\t\t\t  struct ref *ref_map,\n \t\t\t\t  struct fetch_head *fetch_head,\n-\t\t\t\t  const struct fetch_config *config)\n+\t\t\t\t  const struct fetch_config *config,\n+\t\t\t\t  struct ref_update_display_info **display_list,\n+\t\t\t\t  size_t *display_count)\n {\n \tint connectivity_checked = 1;\n \tint ret;\n@@ -1322,7 +1436,8 @@ static int fetch_and_consume_refs(struct display_state *display_state,\n \n \ttrace2_region_enter(\"fetch\", \"consume_refs\", the_repository);\n \tret = store_updated_refs(display_state, connectivity_checked,\n-\t\t\t\t transaction, ref_map, fetch_head, config);\n+\t\t\t\t transaction, ref_map, fetch_head, config,\n+\t\t\t\t display_list, display_count);\n \ttrace2_region_leave(\"fetch\", \"consume_refs\", the_repository);\n \n out:\n@@ -1493,7 +1608,9 @@ static int backfill_tags(struct display_state *display_state,\n \t\t\t struct ref_transaction *transaction,\n \t\t\t struct ref *ref_map,\n \t\t\t struct fetch_head *fetch_head,\n-\t\t\t const struct fetch_config *config)\n+\t\t\t const struct fetch_config *config,\n+\t\t\t struct ref_update_display_info **display_list,\n+\t\t\t size_t *display_count)\n {\n \tint retcode, cannot_reuse;\n \n@@ -1515,7 +1632,7 @@ static int backfill_tags(struct display_state *display_state,\n \ttransport_set_option(transport, TRANS_OPT_DEPTH, \"0\");\n \ttransport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL);\n \tretcode = fetch_and_consume_refs(display_state, transport, transaction, ref_map,\n-\t\t\t\t\t fetch_head, config);\n+\t\t\t\t\t fetch_head, config, display_list, display_count);\n \n \tif (gsecondary) {\n \t\ttransport_disconnect(gsecondary);\n@@ -1641,6 +1758,7 @@ struct ref_rejection_data {\n \tbool conflict_msg_shown;\n \tbool case_sensitive_msg_shown;\n \tconst char *remote_name;\n+\tstruct strmap *rejected_refs;\n };\n \n static void ref_transaction_rejection_handler(const char *refname,\n@@ -1681,6 +1799,7 @@ static void ref_transaction_rejection_handler(const char *refname,\n \t\t\t      refname, ref_transaction_error_msg(err));\n \t}\n \n+\tstrmap_put(data->rejected_refs, refname, NULL);\n \t*data->retcode = 1;\n }\n \n@@ -1690,6 +1809,7 @@ static void ref_transaction_rejection_handler(const char *refname,\n  */\n static int commit_ref_transaction(struct ref_transaction **transaction,\n \t\t\t\t  bool is_atomic, const char *remote_name,\n+\t\t\t\t  struct strmap *rejected_refs,\n \t\t\t\t  struct strbuf *err)\n {\n \tint retcode = ref_transaction_commit(*transaction, err);\n@@ -1701,6 +1821,7 @@ static int commit_ref_transaction(struct ref_transaction **transaction,\n \t\t\t.conflict_msg_shown = 0,\n \t\t\t.remote_name = remote_name,\n \t\t\t.retcode = &retcode,\n+\t\t\t.rejected_refs = rejected_refs,\n \t\t};\n \n \t\tref_transaction_for_each_rejected_update(*transaction,\n@@ -1729,6 +1850,10 @@ static int do_fetch(struct transport *transport,\n \tstruct fetch_head fetch_head = { 0 };\n \tstruct strbuf err = STRBUF_INIT;\n \tint do_set_head = 0;\n+\tstruct ref_update_display_info *display_list = NULL;\n+\tstruct strmap rejected_refs = STRMAP_INIT;\n+\tsize_t display_count = 0;\n+\tint summary_width = 0;\n \n \tif (tags == TAGS_DEFAULT) {\n \t\tif (transport->remote->fetch_tags == 2)\n@@ -1853,7 +1978,7 @@ static int do_fetch(struct transport *transport,\n \t}\n \n \tif (fetch_and_consume_refs(&display_state, transport, transaction, ref_map,\n-\t\t\t\t   &fetch_head, config)) {\n+\t\t\t\t   &fetch_head, config, &display_list, &display_count)) {\n \t\tretcode = 1;\n \t\tgoto cleanup;\n \t}\n@@ -1876,7 +2001,7 @@ static int do_fetch(struct transport *transport,\n \t\t\t * the transaction and don't commit anything.\n \t\t\t */\n \t\t\tif (backfill_tags(&display_state, transport, transaction, tags_ref_map,\n-\t\t\t\t\t  &fetch_head, config))\n+\t\t\t\t\t  &fetch_head, config, &display_list, &display_count))\n \t\t\t\tretcode = 1;\n \t\t}\n \n@@ -1886,8 +2011,12 @@ static int do_fetch(struct transport *transport,\n \tif (retcode)\n \t\tgoto cleanup;\n \n+\tif (verbosity >= 0)\n+\t\tsummary_width = transport_summary_width(ref_map);\n+\n \tretcode = commit_ref_transaction(&transaction, atomic_fetch,\n-\t\t\t\t\t transport->remote->name, &err);\n+\t\t\t\t\t transport->remote->name,\n+\t\t\t\t\t &rejected_refs, &err);\n \t/*\n \t * With '--atomic', bail out if the transaction fails. Without '--atomic',\n \t * continue to fetch head and perform other post-fetch operations.\n@@ -1965,7 +2094,17 @@ static int do_fetch(struct transport *transport,\n \t */\n \tif (retcode && !atomic_fetch && transaction)\n \t\tcommit_ref_transaction(&transaction, false,\n-\t\t\t\t       transport->remote->name, &err);\n+\t\t\t\t       transport->remote->name,\n+\t\t\t\t       &rejected_refs, &err);\n+\n+\tfor (size_t i = 0; i < display_count; i++) {\n+\t\tstruct ref_update_display_info *info = &display_list[i];\n+\n+\t\tif (!info->failed && strmap_contains(&rejected_refs, info->ref))\n+\t\t\tref_update_display_info_set_failed(info);\n+\t\tref_update_display_info_display(info, &display_state, summary_width);\n+\t\tref_update_display_info_free(info);\n+\t}\n \n \tif (retcode) {\n \t\tif (err.len) {\n@@ -1980,6 +2119,9 @@ static int do_fetch(struct transport *transport,\n \n \tif (transaction)\n \t\tref_transaction_free(transaction);\n+\n+\tfree(display_list);\n+\tstrmap_clear(&rejected_refs, 0);\n \tdisplay_state_release(&display_state);\n \tclose_fetch_head(&fetch_head);\n \tstrbuf_release(&err);\ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex 45595991c8..29e2f17608 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -1893,6 +1893,7 @@ test_expect_success 'pushing non-commit objects should report error' '\n \n \t\ttagsha=$(git rev-parse test^{tag}) &&\n \t\ttest_must_fail git push ../dest \"$tagsha:refs/heads/branch\" 2>err &&\n+\t\ttest_grep \"! \\[remote rejected\\] $tagsha -> branch (invalid new value provided)\" err &&\n \t\ttest_grep \"trying to write non-commit object $tagsha to branch ${SQ}refs/heads/branch${SQ}\" err\n \t)\n '\n\n-- \n2.51.2\n\n"},{"id":"534359","messageId":"67808128-5f41-4ae5-b224-a76048cd82c8@gmail.com","threadId":"64834","inReplyTo":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-6-e0edb29acbef@gmail.com","subject":"Re: [PATCH v3 6/6] fetch: delay user information post committing of transaction","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2026-01-21T16:21:20Z","receivedAt":"2026-01-21T16:21:23Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Karthik\n\nOn 20/01/2026 09:59, Karthik Nayak wrote:\n\n> +struct ref_update_display_info {\n> +\tbool failed;\n> +\tchar success_code;\n> +\tchar fail_code;\n> +\tconst char *summary;\n> +\tconst char *fail_detail;\n> +\tconst char *success_detail;\n> +\tconst char *ref;\n> +\tconst char *remote;\n> +\tstruct object_id old_oid;\n> +\tstruct object_id new_oid;\n> +};\n\nI was expecting that we'd pass around a struct like\n\nstruct ref_update_display_info_array {\n\tsize_t alloc, nr;\n\tref_update_display_info *info;\n};\n\nrather than passing a pointer, count pair as separate parameters. That \nwould also allow us to use ALLOC_GROW() rather than reallocating the \narray each time we append to it which is rather inefficient.\n\nThanks\n\nPhillip\n\n> +static struct ref_update_display_info *ref_update_display_info_append(\n> +\t\t\t\t\t   struct ref_update_display_info **list,\n> +\t\t\t\t\t   size_t *count,\n> +\t\t\t\t\t   char success_code,\n> +\t\t\t\t\t   char fail_code,\n> +\t\t\t\t\t   const char *summary,\n> +\t\t\t\t\t   const char *success_detail,\n> +\t\t\t\t\t   const char *fail_detail,\n> +\t\t\t\t\t   const char *ref,\n> +\t\t\t\t\t   const char *remote,\n> +\t\t\t\t\t   const struct object_id *old_oid,\n> +\t\t\t\t\t   const struct object_id *new_oid)\n> +{\n> +\tstruct ref_update_display_info *info;\n> +\tsize_t index = *count;\n> +\n> +\t(*count)++;\n> +\tREALLOC_ARRAY(*list, *count);\n> +\n> +\tinfo = &(*list)[index];\n> +\n> +\tinfo->failed = false;\n> +\tinfo->success_code = success_code;\n> +\tinfo->fail_code = fail_code;\n> +\tinfo->summary = xstrdup(summary);\n> +\tinfo->success_detail = xstrdup_or_null(success_detail);\n> +\tinfo->fail_detail = xstrdup_or_null(fail_detail);\n> +\tinfo->remote = xstrdup(remote);\n> +\tinfo->ref = xstrdup(ref);\n> +\n> +\toidcpy(&info->old_oid, old_oid);\n> +\toidcpy(&info->new_oid, new_oid);\n> +\n> +\treturn info;\n> +}\n> +\n> +static void ref_update_display_info_set_failed(struct ref_update_display_info *info)\n> +{\n> +\tinfo->failed = true;\n> +}\n> +\n> +static void ref_update_display_info_free(struct ref_update_display_info *info)\n> +{\n> +\tfree((char *)info->summary);\n> +\tfree((char *)info->success_detail);\n> +\tfree((char *)info->fail_detail);\n> +\tfree((char *)info->remote);\n> +\tfree((char *)info->ref);\n> +}\n> +\n> +static void ref_update_display_info_display(struct ref_update_display_info *info,\n> +\t\t\t\t\t    struct display_state *display_state,\n> +\t\t\t\t\t    int summary_width)\n> +{\n> +\tdisplay_ref_update(display_state,\n> +\t\t\t   info->failed ? info->fail_code : info->success_code,\n> +\t\t\t   info->summary,\n> +\t\t\t   info->failed ? info->fail_detail : info->success_detail,\n> +\t\t\t   info->remote, info->ref, &info->old_oid,\n> +\t\t\t   &info->new_oid, summary_width);\n> +}\n> +\n>   static int update_local_ref(struct ref *ref,\n>   \t\t\t    struct ref_transaction *transaction,\n> -\t\t\t    struct display_state *display_state,\n>   \t\t\t    const struct ref *remote_ref,\n> -\t\t\t    int summary_width,\n> -\t\t\t    const struct fetch_config *config)\n> +\t\t\t    const struct fetch_config *config,\n> +\t\t\t    struct ref_update_display_info **display_list,\n> +\t\t\t    size_t *display_count)\n>   {\n>   \tstruct commit *current = NULL, *updated;\n>   \tint fast_forward = 0;\n> @@ -877,41 +952,56 @@ static int update_local_ref(struct ref *ref,\n>   \n>   \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n>   \t\tif (verbosity > 0)\n> -\t\t\tdisplay_ref_update(display_state, '=', _(\"[up to date]\"), NULL,\n> -\t\t\t\t\t   remote_ref->name, ref->name,\n> -\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n> +\t\t\tref_update_display_info_append(display_list, display_count,\n> +\t\t\t\t\t\t       '=', '=', _(\"[up to date]\"),\n> +\t\t\t\t\t\t       NULL, NULL, ref->name,\n> +\t\t\t\t\t\t       remote_ref->name, &ref->old_oid,\n> +\t\t\t\t\t\t       &ref->new_oid);\n>   \t\treturn 0;\n>   \t}\n>   \n>   \tif (!update_head_ok &&\n>   \t    !is_null_oid(&ref->old_oid) &&\n>   \t    branch_checked_out(ref->name)) {\n> +\t\tstruct ref_update_display_info *info;\n>   \t\t/*\n>   \t\t * If this is the head, and it's not okay to update\n>   \t\t * the head, and the old value of the head isn't empty...\n>   \t\t */\n> -\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"),\n> -\t\t\t\t   _(\"can't fetch into checked-out branch\"),\n> -\t\t\t\t   remote_ref->name, ref->name,\n> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n> +\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"),\n> +\t\t\t\t\t\t      NULL, _(\"can't fetch into checked-out branch\"),\n> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n> +\t\tref_update_display_info_set_failed(info);\n>   \t\treturn 1;\n>   \t}\n>   \n>   \tif (!is_null_oid(&ref->old_oid) &&\n>   \t    starts_with(ref->name, \"refs/tags/\")) {\n> +\t\tstruct ref_update_display_info *info;\n> +\n>   \t\tif (force || ref->force) {\n>   \t\t\tint r;\n> +\n>   \t\t\tr = s_update_ref(\"updating tag\", ref, transaction, 0);\n> -\t\t\tdisplay_ref_update(display_state, r ? '!' : 't', _(\"[tag update]\"),\n> -\t\t\t\t\t   r ? _(\"unable to update local ref\") : NULL,\n> -\t\t\t\t\t   remote_ref->name, ref->name,\n> -\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n> +\n> +\t\t\tinfo = ref_update_display_info_append(display_list, display_count,\n> +\t\t\t\t\t\t\t      't', '!', _(\"[tag update]\"), NULL,\n> +\t\t\t\t\t\t\t      _(\"unable to update local ref\"),\n> +\t\t\t\t\t\t\t      ref->name, remote_ref->name,\n> +\t\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n> +\t\t\tif (r)\n> +\t\t\t\tref_update_display_info_set_failed(info);\n> +\n>   \t\t\treturn r;\n>   \t\t} else {\n> -\t\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"),\n> -\t\t\t\t\t   _(\"would clobber existing tag\"),\n> -\t\t\t\t\t   remote_ref->name, ref->name,\n> -\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n> +\t\t\tinfo = ref_update_display_info_append(display_list, display_count,\n> +\t\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"), NULL,\n> +\t\t\t\t\t\t\t      _(\"would clobber existing tag\"),\n> +\t\t\t\t\t\t\t      ref->name, remote_ref->name,\n> +\t\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n> +\t\t\tref_update_display_info_set_failed(info);\n>   \t\t\treturn 1;\n>   \t\t}\n>   \t}\n> @@ -921,6 +1011,7 @@ static int update_local_ref(struct ref *ref,\n>   \tupdated = lookup_commit_reference_gently(the_repository,\n>   \t\t\t\t\t\t &ref->new_oid, 1);\n>   \tif (!current || !updated) {\n> +\t\tstruct ref_update_display_info *info;\n>   \t\tconst char *msg;\n>   \t\tconst char *what;\n>   \t\tint r;\n> @@ -941,10 +1032,15 @@ static int update_local_ref(struct ref *ref,\n>   \t\t}\n>   \n>   \t\tr = s_update_ref(msg, ref, transaction, 0);\n> -\t\tdisplay_ref_update(display_state, r ? '!' : '*', what,\n> -\t\t\t\t   r ? _(\"unable to update local ref\") : NULL,\n> -\t\t\t\t   remote_ref->name, ref->name,\n> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n> +\n> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n> +\t\t\t\t\t\t      '*', '!', what, NULL,\n> +\t\t\t\t\t\t      _(\"unable to update local ref\"),\n> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n> +\t\tif (r)\n> +\t\t\tref_update_display_info_set_failed(info);\n> +\n>   \t\treturn r;\n>   \t}\n>   \n> @@ -960,6 +1056,7 @@ static int update_local_ref(struct ref *ref,\n>   \t}\n>   \n>   \tif (fast_forward) {\n> +\t\tstruct ref_update_display_info *info;\n>   \t\tstruct strbuf quickref = STRBUF_INIT;\n>   \t\tint r;\n>   \n> @@ -967,29 +1064,46 @@ static int update_local_ref(struct ref *ref,\n>   \t\tstrbuf_addstr(&quickref, \"..\");\n>   \t\tstrbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);\n>   \t\tr = s_update_ref(\"fast-forward\", ref, transaction, 1);\n> -\t\tdisplay_ref_update(display_state, r ? '!' : ' ', quickref.buf,\n> -\t\t\t\t   r ? _(\"unable to update local ref\") : NULL,\n> -\t\t\t\t   remote_ref->name, ref->name,\n> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n> +\n> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n> +\t\t\t\t\t\t      ' ', '!', quickref.buf, NULL,\n> +\t\t\t\t\t\t      _(\"unable to update local ref\"),\n> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n> +\t\tif (r)\n> +\t\t\tref_update_display_info_set_failed(info);\n> +\n>   \t\tstrbuf_release(&quickref);\n>   \t\treturn r;\n>   \t} else if (force || ref->force) {\n> +\t\tstruct ref_update_display_info *info;\n>   \t\tstruct strbuf quickref = STRBUF_INIT;\n>   \t\tint r;\n> +\n>   \t\tstrbuf_add_unique_abbrev(&quickref, &current->object.oid, DEFAULT_ABBREV);\n>   \t\tstrbuf_addstr(&quickref, \"...\");\n>   \t\tstrbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);\n>   \t\tr = s_update_ref(\"forced-update\", ref, transaction, 1);\n> -\t\tdisplay_ref_update(display_state, r ? '!' : '+', quickref.buf,\n> -\t\t\t\t   r ? _(\"unable to update local ref\") : _(\"forced update\"),\n> -\t\t\t\t   remote_ref->name, ref->name,\n> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n> +\n> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n> +\t\t\t\t\t\t      '+', '!', quickref.buf, _(\"forced update\"),\n> +\t\t\t\t\t\t      _(\"unable to update local ref\"),\n> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n> +\n> +\t\tif (r)\n> +\t\t\tref_update_display_info_set_failed(info);\n> +\n>   \t\tstrbuf_release(&quickref);\n>   \t\treturn r;\n>   \t} else {\n> -\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"), _(\"non-fast-forward\"),\n> -\t\t\t\t   remote_ref->name, ref->name,\n> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n> +\t\tstruct ref_update_display_info *info;\n> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n> +\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"), NULL,\n> +\t\t\t\t\t\t      _(\"non-fast-forward\"),\n> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n> +\t\tref_update_display_info_set_failed(info);\n>   \t\treturn 1;\n>   \t}\n>   }\n> @@ -1103,17 +1217,15 @@ static int store_updated_refs(struct display_state *display_state,\n>   \t\t\t      int connectivity_checked,\n>   \t\t\t      struct ref_transaction *transaction, struct ref *ref_map,\n>   \t\t\t      struct fetch_head *fetch_head,\n> -\t\t\t      const struct fetch_config *config)\n> +\t\t\t      const struct fetch_config *config,\n> +\t\t\t      struct ref_update_display_info **display_list,\n> +\t\t\t      size_t *display_count)\n>   {\n>   \tint rc = 0;\n>   \tstruct strbuf note = STRBUF_INIT;\n>   \tconst char *what, *kind;\n>   \tstruct ref *rm;\n>   \tint want_status;\n> -\tint summary_width = 0;\n> -\n> -\tif (verbosity >= 0)\n> -\t\tsummary_width = transport_summary_width(ref_map);\n>   \n>   \tif (!connectivity_checked) {\n>   \t\tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n> @@ -1218,8 +1330,9 @@ static int store_updated_refs(struct display_state *display_state,\n>   \t\t\t\t\t  display_state->url_len);\n>   \n>   \t\t\tif (ref) {\n> -\t\t\t\trc |= update_local_ref(ref, transaction, display_state,\n> -\t\t\t\t\t\t       rm, summary_width, config);\n> +\t\t\t\trc |= update_local_ref(ref, transaction, rm,\n> +\t\t\t\t\t\t       config, display_list,\n> +\t\t\t\t\t\t       display_count);\n>   \t\t\t\tfree(ref);\n>   \t\t\t} else if (write_fetch_head || dry_run) {\n>   \t\t\t\t/*\n> @@ -1227,12 +1340,11 @@ static int store_updated_refs(struct display_state *display_state,\n>   \t\t\t\t * would be written to FETCH_HEAD, if --dry-run\n>   \t\t\t\t * is set).\n>   \t\t\t\t */\n> -\t\t\t\tdisplay_ref_update(display_state, '*',\n> -\t\t\t\t\t\t   *kind ? kind : \"branch\", NULL,\n> -\t\t\t\t\t\t   rm->name,\n> -\t\t\t\t\t\t   \"FETCH_HEAD\",\n> -\t\t\t\t\t\t   &rm->new_oid, &rm->old_oid,\n> -\t\t\t\t\t\t   summary_width);\n> +\n> +\t\t\t\tref_update_display_info_append(display_list, display_count,\n> +\t\t\t\t\t\t\t       '*', '*', *kind ? kind : \"branch\",\n> +\t\t\t\t\t\t\t       NULL, NULL, \"FETCH_HEAD\", rm->name,\n> +\t\t\t\t\t\t\t       &rm->new_oid, &rm->old_oid);\n>   \t\t\t}\n>   \t\t}\n>   \t}\n> @@ -1300,7 +1412,9 @@ static int fetch_and_consume_refs(struct display_state *display_state,\n>   \t\t\t\t  struct ref_transaction *transaction,\n>   \t\t\t\t  struct ref *ref_map,\n>   \t\t\t\t  struct fetch_head *fetch_head,\n> -\t\t\t\t  const struct fetch_config *config)\n> +\t\t\t\t  const struct fetch_config *config,\n> +\t\t\t\t  struct ref_update_display_info **display_list,\n> +\t\t\t\t  size_t *display_count)\n>   {\n>   \tint connectivity_checked = 1;\n>   \tint ret;\n> @@ -1322,7 +1436,8 @@ static int fetch_and_consume_refs(struct display_state *display_state,\n>   \n>   \ttrace2_region_enter(\"fetch\", \"consume_refs\", the_repository);\n>   \tret = store_updated_refs(display_state, connectivity_checked,\n> -\t\t\t\t transaction, ref_map, fetch_head, config);\n> +\t\t\t\t transaction, ref_map, fetch_head, config,\n> +\t\t\t\t display_list, display_count);\n>   \ttrace2_region_leave(\"fetch\", \"consume_refs\", the_repository);\n>   \n>   out:\n> @@ -1493,7 +1608,9 @@ static int backfill_tags(struct display_state *display_state,\n>   \t\t\t struct ref_transaction *transaction,\n>   \t\t\t struct ref *ref_map,\n>   \t\t\t struct fetch_head *fetch_head,\n> -\t\t\t const struct fetch_config *config)\n> +\t\t\t const struct fetch_config *config,\n> +\t\t\t struct ref_update_display_info **display_list,\n> +\t\t\t size_t *display_count)\n>   {\n>   \tint retcode, cannot_reuse;\n>   \n> @@ -1515,7 +1632,7 @@ static int backfill_tags(struct display_state *display_state,\n>   \ttransport_set_option(transport, TRANS_OPT_DEPTH, \"0\");\n>   \ttransport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL);\n>   \tretcode = fetch_and_consume_refs(display_state, transport, transaction, ref_map,\n> -\t\t\t\t\t fetch_head, config);\n> +\t\t\t\t\t fetch_head, config, display_list, display_count);\n>   \n>   \tif (gsecondary) {\n>   \t\ttransport_disconnect(gsecondary);\n> @@ -1641,6 +1758,7 @@ struct ref_rejection_data {\n>   \tbool conflict_msg_shown;\n>   \tbool case_sensitive_msg_shown;\n>   \tconst char *remote_name;\n> +\tstruct strmap *rejected_refs;\n>   };\n>   \n>   static void ref_transaction_rejection_handler(const char *refname,\n> @@ -1681,6 +1799,7 @@ static void ref_transaction_rejection_handler(const char *refname,\n>   \t\t\t      refname, ref_transaction_error_msg(err));\n>   \t}\n>   \n> +\tstrmap_put(data->rejected_refs, refname, NULL);\n>   \t*data->retcode = 1;\n>   }\n>   \n> @@ -1690,6 +1809,7 @@ static void ref_transaction_rejection_handler(const char *refname,\n>    */\n>   static int commit_ref_transaction(struct ref_transaction **transaction,\n>   \t\t\t\t  bool is_atomic, const char *remote_name,\n> +\t\t\t\t  struct strmap *rejected_refs,\n>   \t\t\t\t  struct strbuf *err)\n>   {\n>   \tint retcode = ref_transaction_commit(*transaction, err);\n> @@ -1701,6 +1821,7 @@ static int commit_ref_transaction(struct ref_transaction **transaction,\n>   \t\t\t.conflict_msg_shown = 0,\n>   \t\t\t.remote_name = remote_name,\n>   \t\t\t.retcode = &retcode,\n> +\t\t\t.rejected_refs = rejected_refs,\n>   \t\t};\n>   \n>   \t\tref_transaction_for_each_rejected_update(*transaction,\n> @@ -1729,6 +1850,10 @@ static int do_fetch(struct transport *transport,\n>   \tstruct fetch_head fetch_head = { 0 };\n>   \tstruct strbuf err = STRBUF_INIT;\n>   \tint do_set_head = 0;\n> +\tstruct ref_update_display_info *display_list = NULL;\n> +\tstruct strmap rejected_refs = STRMAP_INIT;\n> +\tsize_t display_count = 0;\n> +\tint summary_width = 0;\n>   \n>   \tif (tags == TAGS_DEFAULT) {\n>   \t\tif (transport->remote->fetch_tags == 2)\n> @@ -1853,7 +1978,7 @@ static int do_fetch(struct transport *transport,\n>   \t}\n>   \n>   \tif (fetch_and_consume_refs(&display_state, transport, transaction, ref_map,\n> -\t\t\t\t   &fetch_head, config)) {\n> +\t\t\t\t   &fetch_head, config, &display_list, &display_count)) {\n>   \t\tretcode = 1;\n>   \t\tgoto cleanup;\n>   \t}\n> @@ -1876,7 +2001,7 @@ static int do_fetch(struct transport *transport,\n>   \t\t\t * the transaction and don't commit anything.\n>   \t\t\t */\n>   \t\t\tif (backfill_tags(&display_state, transport, transaction, tags_ref_map,\n> -\t\t\t\t\t  &fetch_head, config))\n> +\t\t\t\t\t  &fetch_head, config, &display_list, &display_count))\n>   \t\t\t\tretcode = 1;\n>   \t\t}\n>   \n> @@ -1886,8 +2011,12 @@ static int do_fetch(struct transport *transport,\n>   \tif (retcode)\n>   \t\tgoto cleanup;\n>   \n> +\tif (verbosity >= 0)\n> +\t\tsummary_width = transport_summary_width(ref_map);\n> +\n>   \tretcode = commit_ref_transaction(&transaction, atomic_fetch,\n> -\t\t\t\t\t transport->remote->name, &err);\n> +\t\t\t\t\t transport->remote->name,\n> +\t\t\t\t\t &rejected_refs, &err);\n>   \t/*\n>   \t * With '--atomic', bail out if the transaction fails. Without '--atomic',\n>   \t * continue to fetch head and perform other post-fetch operations.\n> @@ -1965,7 +2094,17 @@ static int do_fetch(struct transport *transport,\n>   \t */\n>   \tif (retcode && !atomic_fetch && transaction)\n>   \t\tcommit_ref_transaction(&transaction, false,\n> -\t\t\t\t       transport->remote->name, &err);\n> +\t\t\t\t       transport->remote->name,\n> +\t\t\t\t       &rejected_refs, &err);\n> +\n> +\tfor (size_t i = 0; i < display_count; i++) {\n> +\t\tstruct ref_update_display_info *info = &display_list[i];\n> +\n> +\t\tif (!info->failed && strmap_contains(&rejected_refs, info->ref))\n> +\t\t\tref_update_display_info_set_failed(info);\n> +\t\tref_update_display_info_display(info, &display_state, summary_width);\n> +\t\tref_update_display_info_free(info);\n> +\t}\n>   \n>   \tif (retcode) {\n>   \t\tif (err.len) {\n> @@ -1980,6 +2119,9 @@ static int do_fetch(struct transport *transport,\n>   \n>   \tif (transaction)\n>   \t\tref_transaction_free(transaction);\n> +\n> +\tfree(display_list);\n> +\tstrmap_clear(&rejected_refs, 0);\n>   \tdisplay_state_release(&display_state);\n>   \tclose_fetch_head(&fetch_head);\n>   \tstrbuf_release(&err);\n> diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\n> index 45595991c8..29e2f17608 100755\n> --- a/t/t5516-fetch-push.sh\n> +++ b/t/t5516-fetch-push.sh\n> @@ -1893,6 +1893,7 @@ test_expect_success 'pushing non-commit objects should report error' '\n>   \n>   \t\ttagsha=$(git rev-parse test^{tag}) &&\n>   \t\ttest_must_fail git push ../dest \"$tagsha:refs/heads/branch\" 2>err &&\n> +\t\ttest_grep \"! \\[remote rejected\\] $tagsha -> branch (invalid new value provided)\" err &&\n>   \t\ttest_grep \"trying to write non-commit object $tagsha to branch ${SQ}refs/heads/branch${SQ}\" err\n>   \t)\n>   '\n> \n\n"},{"id":"534369","messageId":"xmqqtsweu96c.fsf@gitster.g","threadId":"64834","inReplyTo":"20260120-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v3-0-e0edb29acbef@gmail.com","subject":"Re: [PATCH v3 0/6] refs: provide detailed error messages when using batched update","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-21T18:12:27Z","receivedAt":"2026-01-21T18:12:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> The refs namespace uses an error buffer to capture details about failed\n> reference updates. However when we added batched update support to\n> reference transactions, these messages were never propagated, instead\n> only an error code pertaining to the type of failure was propagated.\n>\n> Currently, there are three regions which utilize batched updates:\n>\n>   - git update-ref --batch-updates\n>   - git fetch\n>   - git receive-pack\n>\n> While 'git update-ref --batch-updates' was a newly introduced flag, both\n> 'git fetch' and 'git receive-pack' were pre-existing. Before using\n> batched updates, they provided more detailed error messages to the user,\n> but this changed with the introduction of batched updates. This is a\n> regression in their workings.\n>\n> This patch series fixes this, by passing the detailed error message and\n> utilizing it whenever available. The regression was reported by Elijah\n> Newren [1] and based on the patch submitted by Jeff King [2].\n>\n> [1]: https://lore.kernel.org/all/CABPp-BGL2tJR4dPidQuFcp-X0_VkVTknCY-0Zgo=jHVGv_P=wA@mail.gmail.com/\n> [2]: https://lore.kernel.org/all/20251224081214.GA1879908@coredump.intra.peff.net/\n>\n> ---\n> Changes in v3:\n> - Drop the first commit.\n> - For the last commit, where we delay 'git fetch' status information,\n>   delay all information to the end. Also use a list to compliment the\n>   existing strmap, this ensures that the order is maintained.\n> - Link to v2: https://patch.msgid.link/20260116-633-regression-lost-diagnostic-message-when-pushing-non-commit-objects-to-refs-heads-v2-0-925a0e9c7f32@gmail.com\n\nThanks.  These look good.\n"},{"id":"534372","messageId":"xmqqldhqu7q0.fsf@gitster.g","threadId":"64834","inReplyTo":"67808128-5f41-4ae5-b224-a76048cd82c8@gmail.com","subject":"Re: [PATCH v3 6/6] fetch: delay user information post committing of transaction","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-21T18:43:51Z","receivedAt":"2026-01-21T18:43:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n>> +struct ref_update_display_info {\n>> +\tbool failed;\n>> +\tchar success_code;\n>> +\tchar fail_code;\n>> +\tconst char *summary;\n>> +\tconst char *fail_detail;\n>> +\tconst char *success_detail;\n>> +\tconst char *ref;\n>> +\tconst char *remote;\n>> +\tstruct object_id old_oid;\n>> +\tstruct object_id new_oid;\n>> +};\n>\n> I was expecting that we'd pass around a struct like\n>\n> struct ref_update_display_info_array {\n> \tsize_t alloc, nr;\n> \tref_update_display_info *info;\n> };\n>\n> rather than passing a pointer, count pair as separate parameters. That \n> would also allow us to use ALLOC_GROW() rather than reallocating the \n> array each time we append to it which is rather inefficient.\n>\n> Thanks\n\nIndeed.  That sounds like a sensible way to keep track of them.\n\n>\n> Phillip\n>\n>> +static struct ref_update_display_info *ref_update_display_info_append(\n>> +\t\t\t\t\t   struct ref_update_display_info **list,\n>> +\t\t\t\t\t   size_t *count,\n>> +\t\t\t\t\t   char success_code,\n>> +\t\t\t\t\t   char fail_code,\n>> +\t\t\t\t\t   const char *summary,\n>> +\t\t\t\t\t   const char *success_detail,\n>> +\t\t\t\t\t   const char *fail_detail,\n>> +\t\t\t\t\t   const char *ref,\n>> +\t\t\t\t\t   const char *remote,\n>> +\t\t\t\t\t   const struct object_id *old_oid,\n>> +\t\t\t\t\t   const struct object_id *new_oid)\n>> +{\n>> +\tstruct ref_update_display_info *info;\n>> +\tsize_t index = *count;\n>> +\n>> +\t(*count)++;\n>> +\tREALLOC_ARRAY(*list, *count);\n>> +\n>> +\tinfo = &(*list)[index];\n>> +\n>> +\tinfo->failed = false;\n>> +\tinfo->success_code = success_code;\n>> +\tinfo->fail_code = fail_code;\n>> +\tinfo->summary = xstrdup(summary);\n>> +\tinfo->success_detail = xstrdup_or_null(success_detail);\n>> +\tinfo->fail_detail = xstrdup_or_null(fail_detail);\n>> +\tinfo->remote = xstrdup(remote);\n>> +\tinfo->ref = xstrdup(ref);\n>> +\n>> +\toidcpy(&info->old_oid, old_oid);\n>> +\toidcpy(&info->new_oid, new_oid);\n>> +\n>> +\treturn info;\n>> +}\n>> +\n>> +static void ref_update_display_info_set_failed(struct ref_update_display_info *info)\n>> +{\n>> +\tinfo->failed = true;\n>> +}\n>> +\n>> +static void ref_update_display_info_free(struct ref_update_display_info *info)\n>> +{\n>> +\tfree((char *)info->summary);\n>> +\tfree((char *)info->success_detail);\n>> +\tfree((char *)info->fail_detail);\n>> +\tfree((char *)info->remote);\n>> +\tfree((char *)info->ref);\n>> +}\n>> +\n>> +static void ref_update_display_info_display(struct ref_update_display_info *info,\n>> +\t\t\t\t\t    struct display_state *display_state,\n>> +\t\t\t\t\t    int summary_width)\n>> +{\n>> +\tdisplay_ref_update(display_state,\n>> +\t\t\t   info->failed ? info->fail_code : info->success_code,\n>> +\t\t\t   info->summary,\n>> +\t\t\t   info->failed ? info->fail_detail : info->success_detail,\n>> +\t\t\t   info->remote, info->ref, &info->old_oid,\n>> +\t\t\t   &info->new_oid, summary_width);\n>> +}\n>> +\n>>   static int update_local_ref(struct ref *ref,\n>>   \t\t\t    struct ref_transaction *transaction,\n>> -\t\t\t    struct display_state *display_state,\n>>   \t\t\t    const struct ref *remote_ref,\n>> -\t\t\t    int summary_width,\n>> -\t\t\t    const struct fetch_config *config)\n>> +\t\t\t    const struct fetch_config *config,\n>> +\t\t\t    struct ref_update_display_info **display_list,\n>> +\t\t\t    size_t *display_count)\n>>   {\n>>   \tstruct commit *current = NULL, *updated;\n>>   \tint fast_forward = 0;\n>> @@ -877,41 +952,56 @@ static int update_local_ref(struct ref *ref,\n>>   \n>>   \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n>>   \t\tif (verbosity > 0)\n>> -\t\t\tdisplay_ref_update(display_state, '=', _(\"[up to date]\"), NULL,\n>> -\t\t\t\t\t   remote_ref->name, ref->name,\n>> -\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n>> +\t\t\tref_update_display_info_append(display_list, display_count,\n>> +\t\t\t\t\t\t       '=', '=', _(\"[up to date]\"),\n>> +\t\t\t\t\t\t       NULL, NULL, ref->name,\n>> +\t\t\t\t\t\t       remote_ref->name, &ref->old_oid,\n>> +\t\t\t\t\t\t       &ref->new_oid);\n>>   \t\treturn 0;\n>>   \t}\n>>   \n>>   \tif (!update_head_ok &&\n>>   \t    !is_null_oid(&ref->old_oid) &&\n>>   \t    branch_checked_out(ref->name)) {\n>> +\t\tstruct ref_update_display_info *info;\n>>   \t\t/*\n>>   \t\t * If this is the head, and it's not okay to update\n>>   \t\t * the head, and the old value of the head isn't empty...\n>>   \t\t */\n>> -\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"),\n>> -\t\t\t\t   _(\"can't fetch into checked-out branch\"),\n>> -\t\t\t\t   remote_ref->name, ref->name,\n>> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n>> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n>> +\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"),\n>> +\t\t\t\t\t\t      NULL, _(\"can't fetch into checked-out branch\"),\n>> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n>> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n>> +\t\tref_update_display_info_set_failed(info);\n>>   \t\treturn 1;\n>>   \t}\n>>   \n>>   \tif (!is_null_oid(&ref->old_oid) &&\n>>   \t    starts_with(ref->name, \"refs/tags/\")) {\n>> +\t\tstruct ref_update_display_info *info;\n>> +\n>>   \t\tif (force || ref->force) {\n>>   \t\t\tint r;\n>> +\n>>   \t\t\tr = s_update_ref(\"updating tag\", ref, transaction, 0);\n>> -\t\t\tdisplay_ref_update(display_state, r ? '!' : 't', _(\"[tag update]\"),\n>> -\t\t\t\t\t   r ? _(\"unable to update local ref\") : NULL,\n>> -\t\t\t\t\t   remote_ref->name, ref->name,\n>> -\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n>> +\n>> +\t\t\tinfo = ref_update_display_info_append(display_list, display_count,\n>> +\t\t\t\t\t\t\t      't', '!', _(\"[tag update]\"), NULL,\n>> +\t\t\t\t\t\t\t      _(\"unable to update local ref\"),\n>> +\t\t\t\t\t\t\t      ref->name, remote_ref->name,\n>> +\t\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n>> +\t\t\tif (r)\n>> +\t\t\t\tref_update_display_info_set_failed(info);\n>> +\n>>   \t\t\treturn r;\n>>   \t\t} else {\n>> -\t\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"),\n>> -\t\t\t\t\t   _(\"would clobber existing tag\"),\n>> -\t\t\t\t\t   remote_ref->name, ref->name,\n>> -\t\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n>> +\t\t\tinfo = ref_update_display_info_append(display_list, display_count,\n>> +\t\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"), NULL,\n>> +\t\t\t\t\t\t\t      _(\"would clobber existing tag\"),\n>> +\t\t\t\t\t\t\t      ref->name, remote_ref->name,\n>> +\t\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n>> +\t\t\tref_update_display_info_set_failed(info);\n>>   \t\t\treturn 1;\n>>   \t\t}\n>>   \t}\n>> @@ -921,6 +1011,7 @@ static int update_local_ref(struct ref *ref,\n>>   \tupdated = lookup_commit_reference_gently(the_repository,\n>>   \t\t\t\t\t\t &ref->new_oid, 1);\n>>   \tif (!current || !updated) {\n>> +\t\tstruct ref_update_display_info *info;\n>>   \t\tconst char *msg;\n>>   \t\tconst char *what;\n>>   \t\tint r;\n>> @@ -941,10 +1032,15 @@ static int update_local_ref(struct ref *ref,\n>>   \t\t}\n>>   \n>>   \t\tr = s_update_ref(msg, ref, transaction, 0);\n>> -\t\tdisplay_ref_update(display_state, r ? '!' : '*', what,\n>> -\t\t\t\t   r ? _(\"unable to update local ref\") : NULL,\n>> -\t\t\t\t   remote_ref->name, ref->name,\n>> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n>> +\n>> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n>> +\t\t\t\t\t\t      '*', '!', what, NULL,\n>> +\t\t\t\t\t\t      _(\"unable to update local ref\"),\n>> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n>> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n>> +\t\tif (r)\n>> +\t\t\tref_update_display_info_set_failed(info);\n>> +\n>>   \t\treturn r;\n>>   \t}\n>>   \n>> @@ -960,6 +1056,7 @@ static int update_local_ref(struct ref *ref,\n>>   \t}\n>>   \n>>   \tif (fast_forward) {\n>> +\t\tstruct ref_update_display_info *info;\n>>   \t\tstruct strbuf quickref = STRBUF_INIT;\n>>   \t\tint r;\n>>   \n>> @@ -967,29 +1064,46 @@ static int update_local_ref(struct ref *ref,\n>>   \t\tstrbuf_addstr(&quickref, \"..\");\n>>   \t\tstrbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);\n>>   \t\tr = s_update_ref(\"fast-forward\", ref, transaction, 1);\n>> -\t\tdisplay_ref_update(display_state, r ? '!' : ' ', quickref.buf,\n>> -\t\t\t\t   r ? _(\"unable to update local ref\") : NULL,\n>> -\t\t\t\t   remote_ref->name, ref->name,\n>> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n>> +\n>> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n>> +\t\t\t\t\t\t      ' ', '!', quickref.buf, NULL,\n>> +\t\t\t\t\t\t      _(\"unable to update local ref\"),\n>> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n>> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n>> +\t\tif (r)\n>> +\t\t\tref_update_display_info_set_failed(info);\n>> +\n>>   \t\tstrbuf_release(&quickref);\n>>   \t\treturn r;\n>>   \t} else if (force || ref->force) {\n>> +\t\tstruct ref_update_display_info *info;\n>>   \t\tstruct strbuf quickref = STRBUF_INIT;\n>>   \t\tint r;\n>> +\n>>   \t\tstrbuf_add_unique_abbrev(&quickref, &current->object.oid, DEFAULT_ABBREV);\n>>   \t\tstrbuf_addstr(&quickref, \"...\");\n>>   \t\tstrbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);\n>>   \t\tr = s_update_ref(\"forced-update\", ref, transaction, 1);\n>> -\t\tdisplay_ref_update(display_state, r ? '!' : '+', quickref.buf,\n>> -\t\t\t\t   r ? _(\"unable to update local ref\") : _(\"forced update\"),\n>> -\t\t\t\t   remote_ref->name, ref->name,\n>> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n>> +\n>> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n>> +\t\t\t\t\t\t      '+', '!', quickref.buf, _(\"forced update\"),\n>> +\t\t\t\t\t\t      _(\"unable to update local ref\"),\n>> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n>> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n>> +\n>> +\t\tif (r)\n>> +\t\t\tref_update_display_info_set_failed(info);\n>> +\n>>   \t\tstrbuf_release(&quickref);\n>>   \t\treturn r;\n>>   \t} else {\n>> -\t\tdisplay_ref_update(display_state, '!', _(\"[rejected]\"), _(\"non-fast-forward\"),\n>> -\t\t\t\t   remote_ref->name, ref->name,\n>> -\t\t\t\t   &ref->old_oid, &ref->new_oid, summary_width);\n>> +\t\tstruct ref_update_display_info *info;\n>> +\t\tinfo = ref_update_display_info_append(display_list, display_count,\n>> +\t\t\t\t\t\t      '!', '!', _(\"[rejected]\"), NULL,\n>> +\t\t\t\t\t\t      _(\"non-fast-forward\"),\n>> +\t\t\t\t\t\t      ref->name, remote_ref->name,\n>> +\t\t\t\t\t\t      &ref->old_oid, &ref->new_oid);\n>> +\t\tref_update_display_info_set_failed(info);\n>>   \t\treturn 1;\n>>   \t}\n>>   }\n>> @@ -1103,17 +1217,15 @@ static int store_updated_refs(struct display_state *display_state,\n>>   \t\t\t      int connectivity_checked,\n>>   \t\t\t      struct ref_transaction *transaction, struct ref *ref_map,\n>>   \t\t\t      struct fetch_head *fetch_head,\n>> -\t\t\t      const struct fetch_config *config)\n>> +\t\t\t      const struct fetch_config *config,\n>> +\t\t\t      struct ref_update_display_info **display_list,\n>> +\t\t\t      size_t *display_count)\n>>   {\n>>   \tint rc = 0;\n>>   \tstruct strbuf note = STRBUF_INIT;\n>>   \tconst char *what, *kind;\n>>   \tstruct ref *rm;\n>>   \tint want_status;\n>> -\tint summary_width = 0;\n>> -\n>> -\tif (verbosity >= 0)\n>> -\t\tsummary_width = transport_summary_width(ref_map);\n>>   \n>>   \tif (!connectivity_checked) {\n>>   \t\tstruct check_connected_options opt = CHECK_CONNECTED_INIT;\n>> @@ -1218,8 +1330,9 @@ static int store_updated_refs(struct display_state *display_state,\n>>   \t\t\t\t\t  display_state->url_len);\n>>   \n>>   \t\t\tif (ref) {\n>> -\t\t\t\trc |= update_local_ref(ref, transaction, display_state,\n>> -\t\t\t\t\t\t       rm, summary_width, config);\n>> +\t\t\t\trc |= update_local_ref(ref, transaction, rm,\n>> +\t\t\t\t\t\t       config, display_list,\n>> +\t\t\t\t\t\t       display_count);\n>>   \t\t\t\tfree(ref);\n>>   \t\t\t} else if (write_fetch_head || dry_run) {\n>>   \t\t\t\t/*\n>> @@ -1227,12 +1340,11 @@ static int store_updated_refs(struct display_state *display_state,\n>>   \t\t\t\t * would be written to FETCH_HEAD, if --dry-run\n>>   \t\t\t\t * is set).\n>>   \t\t\t\t */\n>> -\t\t\t\tdisplay_ref_update(display_state, '*',\n>> -\t\t\t\t\t\t   *kind ? kind : \"branch\", NULL,\n>> -\t\t\t\t\t\t   rm->name,\n>> -\t\t\t\t\t\t   \"FETCH_HEAD\",\n>> -\t\t\t\t\t\t   &rm->new_oid, &rm->old_oid,\n>> -\t\t\t\t\t\t   summary_width);\n>> +\n>> +\t\t\t\tref_update_display_info_append(display_list, display_count,\n>> +\t\t\t\t\t\t\t       '*', '*', *kind ? kind : \"branch\",\n>> +\t\t\t\t\t\t\t       NULL, NULL, \"FETCH_HEAD\", rm->name,\n>> +\t\t\t\t\t\t\t       &rm->new_oid, &rm->old_oid);\n>>   \t\t\t}\n>>   \t\t}\n>>   \t}\n>> @@ -1300,7 +1412,9 @@ static int fetch_and_consume_refs(struct display_state *display_state,\n>>   \t\t\t\t  struct ref_transaction *transaction,\n>>   \t\t\t\t  struct ref *ref_map,\n>>   \t\t\t\t  struct fetch_head *fetch_head,\n>> -\t\t\t\t  const struct fetch_config *config)\n>> +\t\t\t\t  const struct fetch_config *config,\n>> +\t\t\t\t  struct ref_update_display_info **display_list,\n>> +\t\t\t\t  size_t *display_count)\n>>   {\n>>   \tint connectivity_checked = 1;\n>>   \tint ret;\n>> @@ -1322,7 +1436,8 @@ static int fetch_and_consume_refs(struct display_state *display_state,\n>>   \n>>   \ttrace2_region_enter(\"fetch\", \"consume_refs\", the_repository);\n>>   \tret = store_updated_refs(display_state, connectivity_checked,\n>> -\t\t\t\t transaction, ref_map, fetch_head, config);\n>> +\t\t\t\t transaction, ref_map, fetch_head, config,\n>> +\t\t\t\t display_list, display_count);\n>>   \ttrace2_region_leave(\"fetch\", \"consume_refs\", the_repository);\n>>   \n>>   out:\n>> @@ -1493,7 +1608,9 @@ static int backfill_tags(struct display_state *display_state,\n>>   \t\t\t struct ref_transaction *transaction,\n>>   \t\t\t struct ref *ref_map,\n>>   \t\t\t struct fetch_head *fetch_head,\n>> -\t\t\t const struct fetch_config *config)\n>> +\t\t\t const struct fetch_config *config,\n>> +\t\t\t struct ref_update_display_info **display_list,\n>> +\t\t\t size_t *display_count)\n>>   {\n>>   \tint retcode, cannot_reuse;\n>>   \n>> @@ -1515,7 +1632,7 @@ static int backfill_tags(struct display_state *display_state,\n>>   \ttransport_set_option(transport, TRANS_OPT_DEPTH, \"0\");\n>>   \ttransport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL);\n>>   \tretcode = fetch_and_consume_refs(display_state, transport, transaction, ref_map,\n>> -\t\t\t\t\t fetch_head, config);\n>> +\t\t\t\t\t fetch_head, config, display_list, display_count);\n>>   \n>>   \tif (gsecondary) {\n>>   \t\ttransport_disconnect(gsecondary);\n>> @@ -1641,6 +1758,7 @@ struct ref_rejection_data {\n>>   \tbool conflict_msg_shown;\n>>   \tbool case_sensitive_msg_shown;\n>>   \tconst char *remote_name;\n>> +\tstruct strmap *rejected_refs;\n>>   };\n>>   \n>>   static void ref_transaction_rejection_handler(const char *refname,\n>> @@ -1681,6 +1799,7 @@ static void ref_transaction_rejection_handler(const char *refname,\n>>   \t\t\t      refname, ref_transaction_error_msg(err));\n>>   \t}\n>>   \n>> +\tstrmap_put(data->rejected_refs, refname, NULL);\n>>   \t*data->retcode = 1;\n>>   }\n>>   \n>> @@ -1690,6 +1809,7 @@ static void ref_transaction_rejection_handler(const char *refname,\n>>    */\n>>   static int commit_ref_transaction(struct ref_transaction **transaction,\n>>   \t\t\t\t  bool is_atomic, const char *remote_name,\n>> +\t\t\t\t  struct strmap *rejected_refs,\n>>   \t\t\t\t  struct strbuf *err)\n>>   {\n>>   \tint retcode = ref_transaction_commit(*transaction, err);\n>> @@ -1701,6 +1821,7 @@ static int commit_ref_transaction(struct ref_transaction **transaction,\n>>   \t\t\t.conflict_msg_shown = 0,\n>>   \t\t\t.remote_name = remote_name,\n>>   \t\t\t.retcode = &retcode,\n>> +\t\t\t.rejected_refs = rejected_refs,\n>>   \t\t};\n>>   \n>>   \t\tref_transaction_for_each_rejected_update(*transaction,\n>> @@ -1729,6 +1850,10 @@ static int do_fetch(struct transport *transport,\n>>   \tstruct fetch_head fetch_head = { 0 };\n>>   \tstruct strbuf err = STRBUF_INIT;\n>>   \tint do_set_head = 0;\n>> +\tstruct ref_update_display_info *display_list = NULL;\n>> +\tstruct strmap rejected_refs = STRMAP_INIT;\n>> +\tsize_t display_count = 0;\n>> +\tint summary_width = 0;\n>>   \n>>   \tif (tags == TAGS_DEFAULT) {\n>>   \t\tif (transport->remote->fetch_tags == 2)\n>> @@ -1853,7 +1978,7 @@ static int do_fetch(struct transport *transport,\n>>   \t}\n>>   \n>>   \tif (fetch_and_consume_refs(&display_state, transport, transaction, ref_map,\n>> -\t\t\t\t   &fetch_head, config)) {\n>> +\t\t\t\t   &fetch_head, config, &display_list, &display_count)) {\n>>   \t\tretcode = 1;\n>>   \t\tgoto cleanup;\n>>   \t}\n>> @@ -1876,7 +2001,7 @@ static int do_fetch(struct transport *transport,\n>>   \t\t\t * the transaction and don't commit anything.\n>>   \t\t\t */\n>>   \t\t\tif (backfill_tags(&display_state, transport, transaction, tags_ref_map,\n>> -\t\t\t\t\t  &fetch_head, config))\n>> +\t\t\t\t\t  &fetch_head, config, &display_list, &display_count))\n>>   \t\t\t\tretcode = 1;\n>>   \t\t}\n>>   \n>> @@ -1886,8 +2011,12 @@ static int do_fetch(struct transport *transport,\n>>   \tif (retcode)\n>>   \t\tgoto cleanup;\n>>   \n>> +\tif (verbosity >= 0)\n>> +\t\tsummary_width = transport_summary_width(ref_map);\n>> +\n>>   \tretcode = commit_ref_transaction(&transaction, atomic_fetch,\n>> -\t\t\t\t\t transport->remote->name, &err);\n>> +\t\t\t\t\t transport->remote->name,\n>> +\t\t\t\t\t &rejected_refs, &err);\n>>   \t/*\n>>   \t * With '--atomic', bail out if the transaction fails. Without '--atomic',\n>>   \t * continue to fetch head and perform other post-fetch operations.\n>> @@ -1965,7 +2094,17 @@ static int do_fetch(struct transport *transport,\n>>   \t */\n>>   \tif (retcode && !atomic_fetch && transaction)\n>>   \t\tcommit_ref_transaction(&transaction, false,\n>> -\t\t\t\t       transport->remote->name, &err);\n>> +\t\t\t\t       transport->remote->name,\n>> +\t\t\t\t       &rejected_refs, &err);\n>> +\n>> +\tfor (size_t i = 0; i < display_count; i++) {\n>> +\t\tstruct ref_update_display_info *info = &display_list[i];\n>> +\n>> +\t\tif (!info->failed && strmap_contains(&rejected_refs, info->ref))\n>> +\t\t\tref_update_display_info_set_failed(info);\n>> +\t\tref_update_display_info_display(info, &display_state, summary_width);\n>> +\t\tref_update_display_info_free(info);\n>> +\t}\n>>   \n>>   \tif (retcode) {\n>>   \t\tif (err.len) {\n>> @@ -1980,6 +2119,9 @@ static int do_fetch(struct transport *transport,\n>>   \n>>   \tif (transaction)\n>>   \t\tref_transaction_free(transaction);\n>> +\n>> +\tfree(display_list);\n>> +\tstrmap_clear(&rejected_refs, 0);\n>>   \tdisplay_state_release(&display_state);\n>>   \tclose_fetch_head(&fetch_head);\n>>   \tstrbuf_release(&err);\n>> diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\n>> index 45595991c8..29e2f17608 100755\n>> --- a/t/t5516-fetch-push.sh\n>> +++ b/t/t5516-fetch-push.sh\n>> @@ -1893,6 +1893,7 @@ test_expect_success 'pushing non-commit objects should report error' '\n>>   \n>>   \t\ttagsha=$(git rev-parse test^{tag}) &&\n>>   \t\ttest_must_fail git push ../dest \"$tagsha:refs/heads/branch\" 2>err &&\n>> +\t\ttest_grep \"! \\[remote rejected\\] $tagsha -> branch (invalid new value provided)\" err &&\n>>   \t\ttest_grep \"trying to write non-commit object $tagsha to branch ${SQ}refs/heads/branch${SQ}\" err\n>>   \t)\n>>   '\n>> \n"},{"id":"534431","messageId":"CAOLa=ZRO1gH_pdo6Z1xpx5N5u=Unfhq7wyV8EHUiB0zp1+AhJw@mail.gmail.com","threadId":"64834","inReplyTo":"67808128-5f41-4ae5-b224-a76048cd82c8@gmail.com","subject":"Re: [PATCH v3 6/6] fetch: delay user information post committing of transaction","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-01-22T09:05:44Z","receivedAt":"2026-01-22T09:05:47Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n> Hi Karthik\n>\n> On 20/01/2026 09:59, Karthik Nayak wrote:\n>\n>> +struct ref_update_display_info {\n>> +\tbool failed;\n>> +\tchar success_code;\n>> +\tchar fail_code;\n>> +\tconst char *summary;\n>> +\tconst char *fail_detail;\n>> +\tconst char *success_detail;\n>> +\tconst char *ref;\n>> +\tconst char *remote;\n>> +\tstruct object_id old_oid;\n>> +\tstruct object_id new_oid;\n>> +};\n>\n> I was expecting that we'd pass around a struct like\n>\n> struct ref_update_display_info_array {\n> \tsize_t alloc, nr;\n> \tref_update_display_info *info;\n> };\n>\n> rather than passing a pointer, count pair as separate parameters. That\n> would also allow us to use ALLOC_GROW() rather than reallocating the\n> array each time we append to it which is rather inefficient.\n>\n> Thanks\n>\n> Phillip\n>\n\nThat's fair, I was considering an array and didn't see the need, but\nusing 'ALLOC_GROW()' does make it simpler, plus we'd totally remove the\nneed for the double pointer. Will change. Thanks!\n"}]}