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

Re: [PATCH] add post-fetch hook

From
Jakub Narebski <jnareb@gmail.com>
Date
Dec 25, 2011, 16:24 UTC
Message-ID
<m3liq0fwkz.fsf@localhost.localdomain>
In-Reply-To
<7vsjk99exw.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 20 quoted lines
> [...] if we were to allow the hook to lie what commits were fetched and store
> something different from what we fetched in the remote tracking refs, I
> think the correct place to do so would be in store_updated_refs(),
> immediately before we call check_everything_connected().
> 
>  - Feed the contents of the ref_map to the hook. For each entry, the hook
>    would get (at least):
>    . the object name;
>    . the refname at the remote;
>    . the refname at the local (which could be empty when we are not
>      copying it to any of our local ref); and
>    . if the entry is to be used for merge.
> 
>  - The hook must read _everything_ from its standard input, and then
>    return the
>    re-written result in the same format as its input. The hook could
>    . update the object name (i.e. re-point the remote tracking ref);
>    . update the local refname (i.e. use different remote tracking ref);
>    . change "merge" flag between true/false; and/or
>    . add or remove entries

This is a very nice idea, IMHO, both because it makes it simple to implement no-op (example) hook by just using "cat", and beause it makes possible to stack such hooks (e.g. one from git-annex with the one from pristine-tar etc.).

One thing that needs to be specified is what should happen if the hook
changes "the refname at the remote" part...
 
Show 7 quoted lines
>  - You read from the hook and replace the ref_map list that is fed to
>    check_everything_connected(). This ref_map list is what is used in the
>    next for() loop that calls update_local_ref() to update the remote
>    tracking ref, records the entry in FETCH_HEAD, and produces the report.
> 
> This way, the hook cannot screw up, as what it tells us will consistently
> be written by us to where it should go.
-- 
Jakub Narebski
Previous: Junio C HamanoNext: Joey Hess
Message 5 of 16 in “add post-fetch hook”
  1. add post-fetch hookJoey Hess, Dec 24, 2011
  2. Junio C HamanoDec 25, 2011
  3. Joey HessDec 25, 2011
  4. Junio C HamanoDec 25, 2011
  5. Jakub NarebskiDec 25, 2011
  6. Joey HessDec 25, 2011
  7. Junio C HamanoDec 26, 2011
  8. Joey HessDec 25, 2011
  9. add post-fetch hookJoey Hess, Dec 26, 2011
  10. Junio C HamanoDec 26, 2011
  11. Joey HessDec 26, 2011
  12. Junio C HamanoDec 27, 2011
  13. Joey HessDec 27, 2011
  14. Junio C HamanoDec 27, 2011
  15. Johannes SixtDec 27, 2011
  16. Joey HessDec 28, 2011

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.