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

Re: [PATCH] Add a sample hook which saves push certs as notes

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 3, 2017, 06:05 UTC
Message-ID
<xmqq609ojqhf.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171203004543.GO3693@zaya.teonanacatl.net>
Todd Zullinger <tmz@pobox.com> writes:
> (I also noticed the tests which use $GIT_PUSH_CERT, like t5534, use
> 'cat-file blob ...' rather than 'cat-file -p ...'.  I don't know if
> that's much safer/better than letting cat-file guess the object type
> in the hook.

The '-p' option is meant for human consumption and we promise that the output from it _will_ change if it makes sense at the UI level.

In a script like this, you do care about the exact byte sequence. So that is a more important reason why you should say "blob" not "-p".

>> +	# Verify that the ref update matches that in push certificate.
>> +	if [[ $push_cert == *$oval" "$nval" "$ref* ]]; then

I am not sure what this expression is trying to do in the first place. The contents of the push certificate blob may contain these three values, but has a lot more than that.

A post-receive is run after all the receive processing is done, so its failing cannot abort the transfer. I wonder how an almost simultaneous push to a same ref, that would not fail normally without this new hook script, would behave. One receive updates the tip from A to B and then starts running this script, while the other receive updates the tip from B to C and then starts running another copy of the script. They both wants to update the notes database but there can be only one winner in the race for its tip.

What happens then? Don't we need to be running a script like this from a hook mechanism that runs under a lock or something?

Previous: Todd ZullingerNext: Shikher Verma
Message 14 of 16 in “Re: [RFC PATCH 0/2] Add named reference to latest push cert”
  1. Stefan BellerSep 6, 2017
  2. Junio C HamanoSep 7, 2017
  3. Shikher VermaSep 7, 2017
  4. Shikher VermaSep 7, 2017
  5. Stefan BellerSep 7, 2017
  6. Shikher VermaSep 16, 2017
  7. Junio C HamanoSep 17, 2017
  8. Santiago TorresSep 18, 2017
  9. Stefan BellerSep 18, 2017
  10. Junio C HamanoSep 19, 2017
  11. Junio C HamanoSep 19, 2017
  12. Add a sample hook which saves push certs as notesShikher Verma, Dec 2, 2017
  13. Todd ZullingerDec 3, 2017
  14. Junio C HamanoDec 3, 2017
  15. Shikher VermaSep 7, 2017
  16. Stefan BellerSep 7, 2017

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.