git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] doc: clarify post-receive hook behavior
@ 2024-07-12 22:47 Justin Tobler
  2024-07-12 23:11 ` Junio C Hamano
  2024-07-14 19:46 ` [PATCH v2] " Justin Tobler
  0 siblings, 2 replies; 8+ messages in thread
From: Justin Tobler @ 2024-07-12 22:47 UTC (permalink / raw)
  To: git; +Cc: Justin Tobler

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 all,

I was recently looking into post-receive hooks and found some of its
documentation[1] a bit misleading. With this patch, the `githooks`
documentation is updated to better align with the hooks documentation
for `git-receive-pack`[2]. Thanks for taking a look!

-Justin

1: https://git-scm.com/docs/githooks#post-receive
2: https://git-scm.com/docs/git-receive-pack#_post_receive_hook
---
 Documentation/githooks.txt | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index 06e997131b..f9eb396a79 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.
+It executes on the remote repository once if any of the attempted ref
+updates are successful.
 
-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
+<<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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] doc: clarify post-receive hook behavior
  2024-07-12 22:47 [PATCH] doc: clarify post-receive hook behavior Justin Tobler
@ 2024-07-12 23:11 ` Junio C Hamano
  2024-07-14 18:54   ` Justin Tobler
  2024-07-14 19:46 ` [PATCH v2] " Justin Tobler
  1 sibling, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2024-07-12 23:11 UTC (permalink / raw)
  To: Justin Tobler; +Cc: git

Justin Tobler <jltobler@gmail.com> writes:

> 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.

Yup, it sounds like is a sensible design that gives the most useful
information to the hook.

> diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
> index 06e997131b..f9eb396a79 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.
> +It executes on the remote repository once if any of the attempted ref
> +updates are successful.

We could instead say "at least one of", but "any of" should be fine.
OK.

> -This hook executes once for the receive operation.  
> +For a receive operation, this hook executes a single time at most.  

Hmph, maybe we can strike this sentence as we already said "once" in
the previous paragraph.  The intention of the original description
that said "only after" was to convey two things:

 (1) it runs only once, and
 (2) it does not run before all the ref-update requests have been
     processed (either successfully or unsuccessfully).  

If the "only after" was not serving the original purpose of
conveying both of the two, then perhaps we should remove the word
"once" from the previous paragraph instead and keep this sentence.

My preference is revert your "once after" -> "once if" to get back
to the original "once after", and then remove "this hook executes
once for the receive operaiton" of the original, without adding your
"For a receieve ... at most".

    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.

> -It takes no
> -arguments, but gets the same information as the
> -<<pre-receive,'pre-receive'>>
> -hook does on its standard input.
> -It
> +takes no arguments, but for each ref successfully updated, it receives a
> +line on standard input that follows the same format as the
> +<<pre-receive,'pre-receive'>> hook.

This part of the update is great.  The "but" there is annoying, but
that badness was inherited from the original and not a fault of this
patch.  If I were writing it from scratch I would probably have said
something like:

    The hook takes no arguments.  It receives one line on standard
    input for each ref that is successfully updated in the same
    format as the pre-receive hook.

Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] doc: clarify post-receive hook behavior
  2024-07-12 23:11 ` Junio C Hamano
@ 2024-07-14 18:54   ` Justin Tobler
  0 siblings, 0 replies; 8+ messages in thread
From: Justin Tobler @ 2024-07-14 18:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 24/07/12 04:11PM, Junio C Hamano wrote:
> Justin Tobler <jltobler@gmail.com> writes:
> 
> > -This hook executes once for the receive operation.  
> > +For a receive operation, this hook executes a single time at most.  
> 
> Hmph, maybe we can strike this sentence as we already said "once" in
> the previous paragraph.  The intention of the original description
> that said "only after" was to convey two things:

Ya, I competely agree that this is repetetive and should be removed. 

> 
>  (1) it runs only once, and
>  (2) it does not run before all the ref-update requests have been
>      processed (either successfully or unsuccessfully).  
> 
> If the "only after" was not serving the original purpose of
> conveying both of the two, then perhaps we should remove the word
> "once" from the previous paragraph instead and keep this sentence.
> 
> My preference is revert your "once after" -> "once if" to get back
> to the original "once after", and then remove "this hook executes
> once for the receive operaiton" of the original, without adding your
> "For a receieve ... at most".
> 
>     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.
> 

Thanks for the suggestion. This more clearly conveys the two points
mentioned. Will add in V2.

> > -It takes no
> > -arguments, but gets the same information as the
> > -<<pre-receive,'pre-receive'>>
> > -hook does on its standard input.
> > -It
> > +takes no arguments, but for each ref successfully updated, it receives a
> > +line on standard input that follows the same format as the
> > +<<pre-receive,'pre-receive'>> hook.
> 
> This part of the update is great.  The "but" there is annoying, but
> that badness was inherited from the original and not a fault of this
> patch.  If I were writing it from scratch I would probably have said
> something like:
> 
>     The hook takes no arguments.  It receives one line on standard
>     input for each ref that is successfully updated in the same
>     format as the pre-receive hook.
> 

I also agree that it is better to break out these two statements. Will
adapt this for V2. Thanks again.

-Justin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] doc: clarify post-receive hook behavior
  2024-07-12 22:47 [PATCH] doc: clarify post-receive hook behavior Justin Tobler
  2024-07-12 23:11 ` Junio C Hamano
@ 2024-07-14 19:46 ` Justin Tobler
  2024-07-15 15:46   ` Junio C Hamano
  2024-07-15 18:37   ` [PATCH v3] " Justin Tobler
  1 sibling, 2 replies; 8+ messages in thread
From: Justin Tobler @ 2024-07-14 19:46 UTC (permalink / raw)
  To: git; +Cc: Justin Tobler

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] doc: clarify post-receive hook behavior
  2024-07-14 19:46 ` [PATCH v2] " Justin Tobler
@ 2024-07-15 15:46   ` Junio C Hamano
  2024-07-15 18:22     ` Justin Tobler
  2024-07-15 18:37   ` [PATCH v3] " Justin Tobler
  1 sibling, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2024-07-15 15:46 UTC (permalink / raw)
  To: Justin Tobler; +Cc: git

Justin Tobler <jltobler@gmail.com> writes:

> +See the link:git-receive-pack.html#_post_receive_hook[post-receive hook]
> +section in linkgit:git-receive-pack[1] for additional details.

Use of link:*.html to point to the HTML version of the manual page
is questionable.  Do we have any example that uses such a link
already?  What would this line do to those who read the manual page,
not HTML, iow, "git receive-pack --help -m"?

The latter link using linkgit: is bog standard and perfectly fine.

Thanks.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] doc: clarify post-receive hook behavior
  2024-07-15 15:46   ` Junio C Hamano
@ 2024-07-15 18:22     ` Justin Tobler
  2024-07-15 18:44       ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Justin Tobler @ 2024-07-15 18:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 24/07/15 08:46AM, Junio C Hamano wrote:
> Justin Tobler <jltobler@gmail.com> writes:
> 
> > +See the link:git-receive-pack.html#_post_receive_hook[post-receive hook]
> > +section in linkgit:git-receive-pack[1] for additional details.
> 
> Use of link:*.html to point to the HTML version of the manual page
> is questionable.  Do we have any example that uses such a link
> already?  What would this line do to those who read the manual page,
> not HTML, iow, "git receive-pack --help -m"?

The manual page for git(1) makes use of link:*.html to point to HTML
documentation.

  - Documentation/git.txt
  - https://git-scm.com/docs/git

In the manual page it appears to specify a path to HTML file in the
NOTES section. I'm not sure this is a good thing though because the file
cannot be expected to exist at the path.

> The latter link using linkgit: is bog standard and perfectly fine.

I think it makes the most sense to drop the link:*html used here and
just rely on the linkgit: reference. I'll adjust this in v3. Thanks for
the feedback.

-Justin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] doc: clarify post-receive hook behavior
  2024-07-14 19:46 ` [PATCH v2] " Justin Tobler
  2024-07-15 15:46   ` Junio C Hamano
@ 2024-07-15 18:37   ` Justin Tobler
  1 sibling, 0 replies; 8+ messages in thread
From: Justin Tobler @ 2024-07-15 18:37 UTC (permalink / raw)
  To: git; +Cc: Justin Tobler

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 third version of my patch to clarify documentation for the
post-receive git hook. Thanks for taking a look.

Changes since v2:
- Removed added usage of link:*.html reference since links to HTML
  documentation in the corresponding manual page are likely to be
  broken. The provided linkgit: reference should be sufficient.

Range-diff against v2:
1:  747e925dfc ! 1:  963e3ddc83 doc: clarify post-receive hook behavior
    @@ Documentation/githooks.txt: environment variables will not be set. If the client
      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.
    ++See the "post-receive" section in linkgit:git-receive-pack[1] for
    ++additional details.
     +
      [[post-update]]
      post-update

 Documentation/githooks.txt | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index 06e997131b..0397dec64d 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 "post-receive" section in linkgit:git-receive-pack[1] for
+additional details.
+
 [[post-update]]
 post-update
 ~~~~~~~~~~~

base-commit: a7dae3bdc8b516d36f630b12bb01e853a667e0d9
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] doc: clarify post-receive hook behavior
  2024-07-15 18:22     ` Justin Tobler
@ 2024-07-15 18:44       ` Junio C Hamano
  0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2024-07-15 18:44 UTC (permalink / raw)
  To: Justin Tobler; +Cc: git

Justin Tobler <jltobler@gmail.com> writes:

> I think it makes the most sense to drop the link:*html used here and
> just rely on the linkgit: reference. I'll adjust this in v3. Thanks for
> the feedback.

That sounds like a sensible and conservative approach.

Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-07-15 18:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12 22:47 [PATCH] doc: clarify post-receive hook behavior Justin Tobler
2024-07-12 23:11 ` Junio C Hamano
2024-07-14 18:54   ` Justin Tobler
2024-07-14 19:46 ` [PATCH v2] " Justin Tobler
2024-07-15 15:46   ` Junio C Hamano
2024-07-15 18:22     ` Justin Tobler
2024-07-15 18:44       ` Junio C Hamano
2024-07-15 18:37   ` [PATCH v3] " Justin Tobler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).