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

Re: [PATCH v4 2/3] receive-pack: move message generation to separate function

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 31, 2026, 06:44 UTC
Message-ID
<apUi62Q_0CFBbBVO@pks.im>
In-Reply-To
<20260826-758-introduce-hook-v4-2-6b14975ad957@gmail.com>
On Wed, Aug 26, 2026 at 12:19:38PM +0200, Karthik Nayak wrote:
Show 8 quoted lines
> Post the reference transaction, both `report()` and `report_v2()`
> generate the message to be sent to the client. In v2, we also add
> reports for each reference if available.
> 
> Since they share common code,
> move them to a common function. This will also help the following
> commit, where we will need to regenerate the message during hook
> failure.
How about this instead:
  After git-receive-pack(1) has committed the reference updates, we call
  either `report()` or `report_v2()` to report to the client which of
  the references we have updated successfully and which updates have
  failed. The only difference between those two functions is that the
  latter also knows to provide a more detailed report about how exactly
  a given reference was updated.
  In the next commit we're about to add another site that wants to
  generate these reports. Refactor the logic into a shared function that
  can easily be reused.
Show 16 quoted lines
> diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
> index 86933d8d7e..70a686c142 100644
> --- a/builtin/receive-pack.c
> +++ b/builtin/receive-pack.c
> @@ -2530,67 +2530,71 @@ static void update_shallow_info(struct command *commands,
>  	free(ref_status);
>  }
>  
> -static void report(struct command *commands, const char *unpack_status)
> +/*
> + * Generate the response to be sent to the client invoking 'git-receive-pack(1)'.
> + * For v2 protocol, set `add_reports` to true, which will also add additional
> + * report per reference update.
> + */
> +static void generate_response(struct strbuf *buf, struct command *commands,
> +			      const char *unpack_status, bool add_reports)

Response sounds quite generic, so should this be renamed to `generate_report()` instead? If so, we could adapt the parameter to `detailed_reports` or somesuch thing.

Other than that this patch looks good to me.
Patrick
Previous: Karthik NayakNext: Karthik Nayak
Message 33 of 98 in “hook: introduce the report hook for git-receive-pack(1)”
  1. hook: introduce the report hook for git-receive-pack(1)Karthik Nayak, Aug 18, 2026
  2. Junio C HamanoAug 18, 2026
  3. Kristoffer HaugsbakkAug 19, 2026
  4. Karthik NayakAug 19, 2026
  5. Kristoffer HaugsbakkAug 19, 2026
  6. Patrick SteinhardtAug 19, 2026
  7. Karthik NayakAug 19, 2026
  8. Patrick SteinhardtAug 19, 2026
  9. Karthik NayakAug 19, 2026
  10. Phillip WoodAug 20, 2026
  11. Junio C HamanoAug 20, 2026
  12. Karthik NayakAug 21, 2026
  13. hook: introduce the report hook for git-receive-pack(1)Karthik Nayak, Aug 21, 2026
  14. Patrick SteinhardtAug 21, 2026
  15. Karthik NayakAug 21, 2026
  16. Patrick SteinhardtAug 24, 2026
  17. Karthik NayakAug 24, 2026
  18. Junio C HamanoAug 21, 2026
  19. 0/3 hook: introduce the report hook for git-receive-pack(1)Karthik Nayak, Aug 24, 2026
  20. 1/3 doc: add proc-receive hook info in 'git-receive-pack.adoc'Karthik Nayak, Aug 24, 2026
  21. 2/3 receive-pack: move message generation to separate functionKarthik Nayak, Aug 24, 2026
  22. 3/3 hook: introduce the report hook for git-receive-pack(1)Karthik Nayak, Aug 24, 2026
  23. Junio C HamanoAug 24, 2026
  24. Junio C HamanoAug 24, 2026
  25. Patrick SteinhardtAug 24, 2026
  26. Karthik NayakAug 26, 2026
  27. Junio C HamanoAug 26, 2026
  28. 0/3 hook: introduce the receive-report hookKarthik Nayak, Aug 26, 2026
  29. 1/3 doc: add proc-receive hook info in 'git-receive-pack.adoc'Karthik Nayak, Aug 26, 2026
  30. Patrick SteinhardtAug 31, 2026
  31. Karthik NayakAug 31, 2026
  32. 2/3 receive-pack: move message generation to separate functionKarthik Nayak, Aug 26, 2026
  33. Patrick SteinhardtAug 31, 2026
  34. Karthik NayakAug 31, 2026
  35. 3/3 hook: introduce the receive-report hookKarthik Nayak, Aug 26, 2026
  36. Patrick SteinhardtAug 31, 2026
  37. 0/3 hook: introduce the receive-report hookKarthik Nayak, Sep 1, 2026
  38. 1/3 doc: add proc-receive hook info in 'git-receive-pack.adoc'Karthik Nayak, Sep 1, 2026
  39. 2/3 receive-pack: move message generation to separate functionKarthik Nayak, Sep 1, 2026
  40. Junio C HamanoSep 1, 2026
  41. Karthik NayakSep 2, 2026
  42. 3/3 hook: introduce the receive-report hookKarthik Nayak, Sep 1, 2026
  43. Junio C HamanoSep 1, 2026
  44. Karthik NayakSep 2, 2026
  45. Junio C HamanoSep 2, 2026
  46. 0/4 hook: introduce the receive-report hookKarthik Nayak, Sep 3, 2026
  47. 1/4 doc: add proc-receive hook info in 'git-receive-pack.adoc'Karthik Nayak, Sep 3, 2026
  48. 2/4 receive-pack: drop static variables to track report status versionKarthik Nayak, Sep 3, 2026
  49. Patrick SteinhardtSep 3, 2026
  50. Karthik NayakSep 3, 2026
  51. 3/4 receive-pack: move message generation to separate functionKarthik Nayak, Sep 3, 2026
  52. Patrick SteinhardtSep 3, 2026
  53. Karthik NayakSep 3, 2026
  54. 4/4 hook: introduce the receive-report hookKarthik Nayak, Sep 3, 2026
  55. Patrick SteinhardtSep 3, 2026
  56. Karthik NayakSep 3, 2026
  57. 0/4 hook: introduce the receive-report hookKarthik Nayak, Sep 4, 2026
  58. 1/4 doc: add proc-receive hook info in 'git-receive-pack.adoc'Karthik Nayak, Sep 4, 2026
  59. 2/4 receive-pack: drop static variables to track report status versionKarthik Nayak, Sep 4, 2026
  60. Junio C HamanoSep 7, 2026
  61. Karthik NayakSep 8, 2026
  62. 3/4 receive-pack: move message generation to separate functionKarthik Nayak, Sep 4, 2026
  63. Junio C HamanoSep 7, 2026
  64. Karthik NayakSep 8, 2026
  65. 4/4 hook: introduce the receive-report hookKarthik Nayak, Sep 4, 2026
  66. Junio C HamanoSep 7, 2026
  67. Karthik NayakSep 8, 2026
  68. Patrick SteinhardtSep 7, 2026
  69. Karthik NayakSep 8, 2026
  70. 0/4 hook: introduce the receive-report hookKarthik Nayak, Sep 8, 2026
  71. 1/4 doc: add proc-receive hook info in 'git-receive-pack.adoc'Karthik Nayak, Sep 8, 2026
  72. 2/4 receive-pack: drop static variables to track report status versionKarthik Nayak, Sep 8, 2026
  73. Junio C HamanoSep 8, 2026
  74. 3/4 receive-pack: move message generation to separate functionKarthik Nayak, Sep 8, 2026
  75. 4/4 hook: introduce the receive-report hookKarthik Nayak, Sep 8, 2026
  76. 0/4 hook: introduce the receive-report hookKarthik Nayak, Sep 9, 2026
  77. 1/4 doc: add proc-receive hook info in 'git-receive-pack.adoc'Karthik Nayak, Sep 9, 2026
  78. 2/4 receive-pack: drop static variables to track report status versionKarthik Nayak, Sep 9, 2026
  79. 3/4 receive-pack: move message generation to separate functionKarthik Nayak, Sep 9, 2026
  80. 4/4 hook: introduce the receive-report hookKarthik Nayak, Sep 9, 2026
  81. Junio C HamanoSep 10, 2026
  82. Karthik NayakSep 10, 2026
  83. Oswald BuddenhagenSep 11, 2026
  84. Karthik NayakSep 11, 2026
  85. Patrick SteinhardtSep 9, 2026
  86. Junio C HamanoSep 9, 2026
  87. Jeff KingSep 10, 2026
  88. Karthik NayakSep 10, 2026
  89. Karthik NayakSep 10, 2026
  90. 0/4 hook: introduce the receive-report hookKarthik Nayak, Sep 10, 2026
  91. 1/4 doc: add proc-receive hook info in 'git-receive-pack.adoc'Karthik Nayak, Sep 10, 2026
  92. 2/4 receive-pack: drop static variables to track report status versionKarthik Nayak, Sep 10, 2026
  93. 3/4 receive-pack: move message generation to separate functionKarthik Nayak, Sep 10, 2026
  94. 4/4 hook: introduce the receive-report hookKarthik Nayak, Sep 10, 2026
  95. Junio C HamanoSep 11, 2026
  96. Karthik NayakSep 11, 2026
  97. Re* [PATCH v10 4/4] hook: introduce the receive-report hookJunio C Hamano, Sep 14, 2026
  98. Karthik NayakSep 15, 2026

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

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