Skip to contentSkip to conversation

git-rebase.txt: add another hook to the hooks section, and explain more

PATCH Superseded Elijah Newren via GitGitGadget 4 participants 6 messages Apr 3, 2020 – Apr 5, 2020 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-rebase.txt: add another hook to the hooks section, and explain more

From: Elijah Newren <[email protected]>

For more discussion about these hooks, their history relative to rebase, and logical consistency between different types of operations, see
https://lore.kernel.org/git/CABPp-BG0bFKUage5cN_2yr2DkmS04W2Z9Pg5WcROqHznV3XBdw@mail.gmail.com/
and the links to some threads referenced therein.

---
git-rebase.txt: add another hook to the hooks section, and explain more

I'm particularly interested in opinions on the last sentence added to the manpage, which is based on the thread mentioned in the commit message.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-749%2Fnewren%2Frebase-and-hooks-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-749/newren/rebase-and-hooks-v1
Pull-Request: https://github.com/git/git/pull/749

 Documentation/git-rebase.txt | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Documentation/git-rebase.txt +9 -3
index f7a6033607f..5c518ca0ccf 100644
@@ -684,9 +684,15 @@ Hooks
 ~~~~~
 
 The apply backend has not traditionally called the post-commit hook,
-while the merge backend has.  However, this was by accident of
-implementation rather than by design.  Both backends should have the
-same behavior, though it is not clear which one is correct.
+while the merge backend has.  In contrast, the apply backend has
+traditionally called the post-checkout hook while the merge backend
+has not.  However, the calling of these hooks in both cases was by
+accident of implementation rather than by design (both backends were
+originally implemented as shell scripts and happened to invoke other
+commands like 'git checkout' or 'git commit' that would call the
+hooks).  Both backends should have the same behavior, though it is not
+entirely clear which, if any, is correct.  We will likely remove both
+of these hooks in the future.
 
 Interruptability
 ~~~~~~~~~~~~~~~~

base-commit: 274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925

Signature · 1 line
gitgitgadget
#1 lore raw

Documentation/git-rebase.txt Hooks · line 695

Quoted 10 lines · Elijah Newren via GitGitGadget

The apply backend has not traditionally called the post-commit hook,

Documentation/git-rebase.txt +9 -0
+while the merge backend has.  In contrast, the apply backend has
+traditionally called the post-checkout hook while the merge backend
+has not.  However, the calling of these hooks in both cases was by
+accident of implementation rather than by design (both backends were
+originally implemented as shell scripts and happened to invoke other
+commands like 'git checkout' or 'git commit' that would call the
+hooks).  Both backends should have the same behavior, though it is not
+entirely clear which, if any, is correct.  We will likely remove both
+of these hooks in the future.

I'd phrase, instead of "remove", "stop calling from 'git rebase'". These hooks will still be called from their intended context ;-)

#2 lore raw
Quoted 16 lines · Junio C Hamano

Documentation/git-rebase.txt Hooks · line 695

Quoted 10 lines · Elijah Newren via GitGitGadget

The apply backend has not traditionally called the post-commit hook,

Documentation/git-rebase.txt +9 -0
+while the merge backend has.  In contrast, the apply backend has
+traditionally called the post-checkout hook while the merge backend
+has not.  However, the calling of these hooks in both cases was by
+accident of implementation rather than by design (both backends were
+originally implemented as shell scripts and happened to invoke other
+commands like 'git checkout' or 'git commit' that would call the
+hooks).  Both backends should have the same behavior, though it is not
+entirely clear which, if any, is correct.  We will likely remove both
+of these hooks in the future.

I'd phrase, instead of "remove", "stop calling from 'git rebase'". These hooks will still be called from their intended context ;-)

Makes sense; I'll update it.

#3 lore raw

PATCH v2 1/1 git-rebase.txt: add another hook to the hooks section, and explain more

In reply to Elijah Newren via GitGitGadget

From: Elijah Newren <[email protected]>

For more discussion about these hooks, their history relative to rebase, and logical consistency between different types of operations, see
https://lore.kernel.org/git/CABPp-BG0bFKUage5cN_2yr2DkmS04W2Z9Pg5WcROqHznV3XBdw@mail.gmail.com/
and the links to some threads referenced therein.

---
git-rebase.txt: add another hook to the hooks section, and explain more

Changes since v1:

* Updated the wording of the last sentence as per Junio's suggestion.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-749%2Fnewren%2Frebase-and-hooks-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-749/newren/rebase-and-hooks-v2
Pull-Request: https://github.com/git/git/pull/749

Range-diff vs v1:

1: 29a1ff520ba ! 1: 45a5c1c1ff9 git-rebase.txt: add another hook to the hooks section, and explain more
@@ Documentation/git-rebase.txt: Hooks
+originally implemented as shell scripts and happened to invoke other
+commands like 'git checkout' or 'git commit' that would call the
+hooks). Both backends should have the same behavior, though it is not
-+entirely clear which, if any, is correct. We will likely remove both
-+of these hooks in the future.
++entirely clear which, if any, is correct. We will likely make rebase
++stop calling either of these hooks in the future.

Interruptability
~~~~~~~~~~~~~~~~

 Documentation/git-rebase.txt | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Documentation/git-rebase.txt +9 -3
index f7a6033607f..5e0fcd4e9bd 100644
@@ -684,9 +684,15 @@ Hooks
 ~~~~~
 
 The apply backend has not traditionally called the post-commit hook,
-while the merge backend has.  However, this was by accident of
-implementation rather than by design.  Both backends should have the
-same behavior, though it is not clear which one is correct.
+while the merge backend has.  In contrast, the apply backend has
+traditionally called the post-checkout hook while the merge backend
+has not.  However, the calling of these hooks in both cases was by
+accident of implementation rather than by design (both backends were
+originally implemented as shell scripts and happened to invoke other
+commands like 'git checkout' or 'git commit' that would call the
+hooks).  Both backends should have the same behavior, though it is not
+entirely clear which, if any, is correct.  We will likely make rebase
+stop calling either of these hooks in the future.
 
 Interruptability
 ~~~~~~~~~~~~~~~~

base-commit: 274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925

Signature · 1 line
gitgitgadget
#4 lore raw

Hi Elijah

Quoted 43 lines · Elijah Newren via GitGitGadget

From: Elijah Newren <[email protected]>

For more discussion about these hooks, their history relative to rebase, and logical consistency between different types of operations, see
https://lore.kernel.org/git/CABPp-BG0bFKUage5cN_2yr2DkmS04W2Z9Pg5WcROqHznV3XBdw@mail.gmail.com/
and the links to some threads referenced therein.

---
git-rebase.txt: add another hook to the hooks section, and explain more

Changes since v1:

* Updated the wording of the last sentence as per Junio's suggestion.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-749%2Fnewren%2Frebase-and-hooks-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-749/newren/rebase-and-hooks-v2
Pull-Request: https://github.com/git/git/pull/749

Range-diff vs v1:

1: 29a1ff520ba ! 1: 45a5c1c1ff9 git-rebase.txt: add another hook to the hooks section, and explain more
@@ Documentation/git-rebase.txt: Hooks
+originally implemented as shell scripts and happened to invoke other
+commands like 'git checkout' or 'git commit' that would call the
+hooks). Both backends should have the same behavior, though it is not
-+entirely clear which, if any, is correct. We will likely remove both
-+of these hooks in the future.
++entirely clear which, if any, is correct. We will likely make rebase
++stop calling either of these hooks in the future.

Interruptability
~~~~~~~~~~~~~~~~

  Documentation/git-rebase.txt | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)
Documentation/git-rebase.txt +0 -0
index f7a6033607f..5e0fcd4e9bd 100644

Documentation/git-rebase.txt Hooks · line 689

Quoted 9 lines
Documentation/git-rebase.txt +3 -3
@@ -684,9 +684,15 @@ Hooks
  ~~~~~
 
  The apply backend has not traditionally called the post-commit hook,
-while the merge backend has.  However, this was by accident of
-implementation rather than by design.  Both backends should have the
-same behavior, though it is not clear which one is correct.
+while the merge backend has.  In contrast, the apply backend has
+traditionally called the post-checkout hook while the merge backend
+has not. 

This is not correct - both backends call the post-checkout hook, but the merge backend suppresses any output from it - see https://public-inbox.org/git/[email protected]/

Best Wishes

Phillip

Quoted 13 lines

However, the calling of these hooks in both cases was by

Documentation/git-rebase.txt +6 -0
+accident of implementation rather than by design (both backends were
+originally implemented as shell scripts and happened to invoke other
+commands like 'git checkout' or 'git commit' that would call the
+hooks).  Both backends should have the same behavior, though it is not
+entirely clear which, if any, is correct.  We will likely make rebase
+stop calling either of these hooks in the future.
 
  Interruptability
  ~~~~~~~~~~~~~~~~

base-commit: 274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925

#5 lore raw

PATCH v3 1/1 git-rebase.txt: add another hook to the hooks section, and explain more

In reply to Elijah Newren via GitGitGadget

From: Elijah Newren <[email protected]>

For more discussion about these hooks, their history relative to rebase, and logical consistency between different types of operations, see
https://lore.kernel.org/git/CABPp-BG0bFKUage5cN_2yr2DkmS04W2Z9Pg5WcROqHznV3XBdw@mail.gmail.com/
and the links to some threads referenced therein.

---
git-rebase.txt: add another hook to the hooks section, and explain more

Changes since v2:

* Corrections to the text pointed out by Phillip.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-749%2Fnewren%2Frebase-and-hooks-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-749/newren/rebase-and-hooks-v3
Pull-Request: https://github.com/git/git/pull/749

Range-diff vs v2:

1: 45a5c1c1ff9 ! 1: 22fb6ff7080 git-rebase.txt: add another hook to the hooks section, and explain more
@@ Documentation/git-rebase.txt: Hooks
-while the merge backend has. However, this was by accident of
-implementation rather than by design. Both backends should have the
-same behavior, though it is not clear which one is correct.
-+while the merge backend has. In contrast, the apply backend has
-+traditionally called the post-checkout hook while the merge backend
-+has not. However, the calling of these hooks in both cases was by
-+accident of implementation rather than by design (both backends were
-+originally implemented as shell scripts and happened to invoke other
-+commands like 'git checkout' or 'git commit' that would call the
-+hooks). Both backends should have the same behavior, though it is not
-+entirely clear which, if any, is correct. We will likely make rebase
-+stop calling either of these hooks in the future.
++while the merge backend has. Both have called the post-checkout hook,
++though the merge backend has squelched its output. Further, both
++backends only call the post-checkout hook with the starting point
++commit of the rebase, not the intermediate commits nor the final
++commit. In each case, the calling of these hooks was by accident of ++implementation rather than by design (both backends were originally
++implemented as shell scripts and happened to invoke other commands
++like 'git checkout' or 'git commit' that would call the hooks). Both
++backends should have the same behavior, though it is not entirely
++clear which, if any, is correct. We will likely make rebase stop
++calling either of these hooks in the future.

Interruptability
~~~~~~~~~~~~~~~~

 Documentation/git-rebase.txt | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
Documentation/git-rebase.txt +11 -3
index f7a6033607f..5a756b5b3a6 100644
@@ -684,9 +684,17 @@ Hooks
 ~~~~~
 
 The apply backend has not traditionally called the post-commit hook,
-while the merge backend has.  However, this was by accident of
-implementation rather than by design.  Both backends should have the
-same behavior, though it is not clear which one is correct.
+while the merge backend has.  Both have called the post-checkout hook,
+though the merge backend has squelched its output.  Further, both
+backends only call the post-checkout hook with the starting point
+commit of the rebase, not the intermediate commits nor the final
+commit.  In each case, the calling of these hooks was by accident of
+implementation rather than by design (both backends were originally
+implemented as shell scripts and happened to invoke other commands
+like 'git checkout' or 'git commit' that would call the hooks).  Both
+backends should have the same behavior, though it is not entirely
+clear which, if any, is correct.  We will likely make rebase stop
+calling either of these hooks in the future.
 
 Interruptability
 ~~~~~~~~~~~~~~~~

base-commit: 274b9cc25322d9ee79aa8e6d4e86f0ffe5ced925

Signature · 1 line
gitgitgadget