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

Re: Fetch-hooks

From
LGLeo Gaspard <leo@gaspard.io>
Date
Feb 10, 2018, 01:33 UTC
Message-ID
<9ab95c53-61e5-06a3-535e-a8916b3e5ec1@gaspard.io>
In-Reply-To
<xmqqvaf5tzw6.fsf@gitster-ct.c.googlers.com>
On 02/10/2018 02:08 AM, Junio C Hamano wrote:
Show 25 quoted lines
> Leo Gaspard <leo@gaspard.io> writes:
> 
>> On 02/10/2018 01:13 AM, Jeff King wrote:
>>> On Sat, Feb 10, 2018 at 12:49:31AM +0100, Leo Gaspard wrote:
>>>> So the changes that are required are:
>>>>  * Adding a notification-only post-fetch hook
> 
> Maybe I missed a very early part of the discussion, but why does
> this even need a hook?  There are some numbers [*1*] of classes of
> valid reasons we may want to have hooks triggered by operations, but
> "always do something locally after doing something else locally,
> regardless of the outcome of that something else" feels like the
> most typical anti-pattern that we do not want a hook for.  If you
> are doing "git fetch" (or "git pull"), you already know you are
> doing that and you donot need a notification.  You just create a
> workflow specific script that calls fetch or pull, followed by
> whatever you want to do and use that, instead of doing "git pull",
> and that is not any extra work than writing a hook and installing
> it.
> 
> Unlike something like post-receive, which happens on the remote side
> where you may not even have an interactive access to, in response to
> the operation you locally do (i.e. "git push"), fetching and then
> doing something else in a repository you fetch into has no reason to
> be done as a hook.
I guess the very early part of the discussion you're speaking of is what
I was assuming after reading
    https://marc.info/?l=git&m=132478296309094&w=2

Then, it's always possible to just write workflow-specific scripts that manually run git fetch then copy the refs (resp. run git fetch then copy the refs then run git merge) to get git myfetch (resp. git mypull) [1].

But then, the question is, why is there a pre-push hook? it's already possible to have a custom script that first runs the hook then runs git push, for most if not all of the use cases of the pre-push hook. Yet the possibility to not change the end-user's workflow is what makes pre-push (or pre-commit, with which the similarity is perhaps even more obvious) so useful.

So the reason for a post-fetch in my opinion is the same as for a pre-push / pre-commit: not changing the user's workflow, while providing additional features.

[1]

Which makes me notice that actually the post-fetch hook technique we were discussing with Peff suffers the same not-updating-FETCH_HEAD issue that was discussed in this early thread: a `git pull` would try to merge from refs/quarantine, I guess. So things are a bit harder than we thought.

I guess the tweak-fetch hook could be left “as-is”, but with git automatically doing the “quarantine-ing” thing transparently so that the references that the end-user (or the hook for that matter) see are the “curated” ones? Then it's too late for me to think efficiently right now, so that idea may be stupid or over-complex.

Previous: Junio C HamanoNext: Leo Gaspard
Message 17 of 38 in “Fetch-hooks”
  1. Leo GaspardFeb 7, 2018
  2. Ævar Arnfjörð BjarmasonFeb 7, 2018
  3. Leo GaspardFeb 8, 2018
  4. Joey HessFeb 8, 2018
  5. Leo GaspardFeb 8, 2018
  6. Ævar Arnfjörð BjarmasonFeb 8, 2018
  7. Leo GaspardFeb 8, 2018
  8. Ævar Arnfjörð BjarmasonFeb 9, 2018
  9. Leo GaspardFeb 9, 2018
  10. Ævar Arnfjörð BjarmasonFeb 9, 2018
  11. Jeff KingFeb 9, 2018
  12. Junio C HamanoFeb 9, 2018
  13. Leo GaspardFeb 9, 2018
  14. Jeff KingFeb 10, 2018
  15. Leo GaspardFeb 10, 2018
  16. Junio C HamanoFeb 10, 2018
  17. Leo GaspardFeb 10, 2018
  18. Leo GaspardFeb 10, 2018
  19. Jeff KingFeb 10, 2018
  20. Leo GaspardFeb 10, 2018
  21. Brandon WilliamsFeb 12, 2018
  22. Leo GaspardFeb 13, 2018
  23. Jeff KingFeb 14, 2018
  24. Jeff KingFeb 14, 2018
  25. Leo GaspardFeb 14, 2018
  26. Jeff KingFeb 19, 2018
  27. Leo GaspardFeb 19, 2018
  28. Jacob KellerFeb 20, 2018
  29. Jeff KingFeb 20, 2018
  30. Leo GaspardFeb 20, 2018
  31. Jacob KellerFeb 14, 2018
  32. Leo GaspardFeb 9, 2018
  33. Joey HessFeb 9, 2018
  34. 0/2 fetch: add tweak-fetch hookLeo Gaspard, Feb 9, 2018
  35. 1/2 fetch: preparations for tweak-fetch hookLeo Gaspard, Feb 9, 2018
  36. 2/2 fetch: add tweak-fetch hookLeo Gaspard, Feb 9, 2018
  37. Junio C HamanoFeb 9, 2018
  38. Junio C HamanoFeb 9, 2018

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.