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

[PATCH v2] doc: clarify post-receive hook behavior

From
Justin Tobler <jltobler@gmail.com>
Date
Jul 14, 2024, 19:46 UTC
Message-ID
<20240714194626.29512-2-jltobler@gmail.com>
In-Reply-To
<20240712224748.56843-1-jltobler@gmail.com>

The `githooks` documentation mentions that the post-receive hook executes once after git-receive-pack(1) updates all references and that it also receives the same information as the pre-receive hook on standard input. This is misleading though because the hook only executes once if at least one of the attempted reference updates is successful. Also, while each line provided on standard input is in the same format as the pre-receive hook, the information received only includes the set of references that were successfully updated.

Update the documentation to clarify these points and also provide a reference to the post-receive hook section of the `git-receive-pack` documentation which has additional information.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
Greetings again,

This is the second version of my patch for post-receive hook documentation updates. Thanks again for taking a look.

-Justin
Changes from v1:
- Removed repetivitve statement about the hook being executed once.
- Slightly reworded statements to improve clarity.
Range-diff against v1:
1:  e4824ba60d ! 1:  747e925dfc doc: clarify post-receive hook behavior
    @@ Documentation/githooks.txt: post-receive
      `git push` and updates reference(s) in its repository.
     -It executes on the remote repository once after all the refs have
     -been updated.
    -+It executes on the remote repository once if any of the attempted ref
    -+updates are successful.
    ++The hook executes on the remote repository once after all the proposed
    ++ref updates are processed and if at least one ref is updated as the
    ++result.
      
     -This hook executes once for the receive operation.  It takes no
     -arguments, but gets the same information as the
     -<<pre-receive,'pre-receive'>>
     -hook does on its standard input.
    -+For a receive operation, this hook executes a single time at most.  It
    -+takes no arguments, but for each ref successfully updated, it receives a
    -+line on standard input that follows the same format as the
    ++The hook takes no arguments.  It receives one line on standard input for
    ++each ref that is successfully updated following the same format as the
     +<<pre-receive,'pre-receive'>> hook.
      
      This hook does not affect the outcome of `git receive-pack`, as it
 Documentation/githooks.txt | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index 06e997131b..5459a40326 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -415,13 +415,13 @@ post-receive
 
 This hook is invoked by linkgit:git-receive-pack[1] when it reacts to
 `git push` and updates reference(s) in its repository.
-It executes on the remote repository once after all the refs have
-been updated.
+The hook executes on the remote repository once after all the proposed
+ref updates are processed and if at least one ref is updated as the
+result.
 
-This hook executes once for the receive operation.  It takes no
-arguments, but gets the same information as the
-<<pre-receive,'pre-receive'>>
-hook does on its standard input.
+The hook takes no arguments.  It receives one line on standard input for
+each ref that is successfully updated following the same format as the
+<<pre-receive,'pre-receive'>> hook.
 
 This hook does not affect the outcome of `git receive-pack`, as it
 is called after the real work is done.
@@ -448,6 +448,9 @@ environment variables will not be set. If the client selects
 to use push options, but doesn't transmit any, the count variable
 will be set to zero, `GIT_PUSH_OPTION_COUNT=0`.
 
+See the link:git-receive-pack.html#_post_receive_hook[post-receive hook]
+section in linkgit:git-receive-pack[1] for additional details.
+
 [[post-update]]
 post-update
 ~~~~~~~~~~~

base-commit: a7dae3bdc8b516d36f630b12bb01e853a667e0d9
-- 
2.45.2
Previous: Justin ToblerNext: Junio C Hamano
Message 4 of 8 in “doc: clarify post-receive hook behavior”
  1. doc: clarify post-receive hook behaviorJustin Tobler, Jul 12, 2024
  2. Junio C HamanoJul 12, 2024
  3. Justin ToblerJul 14, 2024
  4. doc: clarify post-receive hook behaviorJustin Tobler, Jul 14, 2024
  5. Junio C HamanoJul 15, 2024
  6. Justin ToblerJul 15, 2024
  7. Junio C HamanoJul 15, 2024
  8. doc: clarify post-receive hook behaviorJustin Tobler, Jul 15, 2024

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.