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

Re: [PATCH RESEND] refs: Always pass old object name to reftx hook

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 18, 2021, 22:45 UTC
Message-ID
<xmqq4kjdkgol.fsf@gitster.c.googlers.com>
In-Reply-To
<ae5c3b2b783f912a02b26142ecd753bf92530d2f.1610974040.git.ps@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 8 quoted lines
> Inputs of the reference-transaction hook currently depends on the
> command which is being run. For example if the command `git update-ref
> $REF $A $B` is executed, it will receive "$B $A $REF" as input, but if
> the command `git update-ref $REF $A` is executed without providing the
> old value, then it will receive "0*40 $A $REF" as input. This is due to
> the fact that we directly write queued transaction updates into the
> hook's standard input, which will not contain the old object value in
> case it wasn't provided.

In effect, the user says "I do not care if this update races with somebody else and it is perfectly OK if it overwrites their update" by not giving $B.

Show 8 quoted lines
> While this behaviour reflects what is happening as part of the
> repository, it doesn't feel like it is useful. The main intent of the
> reference-transaction hook is to be able to completely audit all
> reference updates, no matter where they come from. As such, it makes a
> lot more sense to always provide actual values instead of what the user
> wanted. Furthermore, it's impossible for the hook to distinguish whether
> this is intended to be a branch creation or a branch update without
> doing additional digging with the current format.

But shouldn't the transaction hook script be allowed to learn the end-user intention and behave differently? If we replace the missing old object before calling the script, wouldn't it lose information?

The above is not an objection posed as two rhetoric questions. I am purely curious why losing information is OK in this case, or why it may not be so OK but should still be acceptable because it is lessor evil than giving 0{40} to the hooks.

Even without this change, the current value the hook can learn by looking the ref up itself if it really wanted to, no?

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 9 of 13 in “refs: Always pass old object name to reftx hook”
  1. refs: Always pass old object name to reftx hookPatrick Steinhardt, Nov 4, 2020
  2. Patrick SteinhardtDec 4, 2020
  3. Taylor BlauJan 12, 2021
  4. Patrick SteinhardtJan 13, 2021
  5. Taylor BlauJan 13, 2021
  6. Junio C HamanoJan 13, 2021
  7. Patrick SteinhardtJan 18, 2021
  8. refs: Always pass old object name to reftx hookPatrick Steinhardt, Jan 18, 2021
  9. Junio C HamanoJan 18, 2021
  10. Patrick SteinhardtJan 20, 2021
  11. Junio C HamanoJan 20, 2021
  12. Patrick SteinhardtJan 22, 2021
  13. Junio C HamanoJan 22, 2021

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.