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

Re: [PATCH v3] Allow update hooks to update refs on their own

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 28, 2007, 23:42 UTC
Message-ID
<7vve7m0wfo.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20071128230355.GB13964@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 23 quoted lines
> On Wed, Nov 28, 2007 at 02:14:03PM -0800, Steven Grimm wrote:
>
>> @@ -177,7 +179,16 @@ static int receive_status(int in, struct ref *refs)
>>  
>>  		line[strlen(line)-1] = '\0';
>>  		refname = line + 3;
>> -		msg = strchr(refname, ' ');
>> +		newsha1_hex = strchr(refname, ' ');
>> +		if (newsha1_hex) {
>> +			*newsha1_hex++ = '\0';
>> +			if (get_sha1_hex(newsha1_hex, newsha1)) {
>> +				fprintf(stderr, "protocol error: bad sha1 %s\n",
>> +					newsha1_hex);
>> +				newsha1_hex = NULL;
>> +			}
>> +		}
>> +		msg = strchr(newsha1_hex, ' ');
>>  		if (msg)
>>  			*msg++ = '\0';
>
> Doesn't this always put the first "word" of a response into newsha1_hex?
> We want to do this only for 'ok' responses; 'ng' responses are already
> using that space as part of the error message.

I do not think reporting back the rewritten object name makes much sense nor adds any value; it won't be useful information until you fetch the object.

I do not think reporting back _anything_ other than "ok" adds much value at all. Sure, if the update hook did something funky you would get such a report, but the situation is not any different if some warm body is sitting on the other end and building on top of what you pushed immediately he sees any push into the repository, and in such a case your git-push would not get any such reporting anyway.

We do not even have to worry about this reporting at all if we do not allow munging the refs in the update hook. In a sense, this patch is creating a problem that does not need to be solved. Perhaps modifying update hook to allow so makes it possible to munge refs while holding a lock, but is it really worth this hassle? Isn't there a better way, I wonder?

Previous: Jeff KingNext: Steven Grimm
Message 18 of 44 in “Allow update hooks to update refs on their own”
  1. Allow update hooks to update refs on their ownSteven Grimm, Nov 27, 2007
  2. Jakub NarebskiNov 27, 2007
  3. Steven GrimmNov 27, 2007
  4. Junio C HamanoNov 28, 2007
  5. Steven GrimmNov 28, 2007
  6. Daniel BarkalowNov 28, 2007
  7. Junio C HamanoNov 28, 2007
  8. Steven GrimmNov 28, 2007
  9. Jeff KingNov 28, 2007
  10. Junio C HamanoNov 28, 2007
  11. Allow update hooks to update refs on their ownSteven Grimm, Nov 28, 2007
  12. Jeff KingNov 28, 2007
  13. Steven GrimmNov 28, 2007
  14. Jeff KingNov 28, 2007
  15. Junio C HamanoNov 28, 2007
  16. Allow update hooks to update refs on their ownSteven Grimm, Nov 28, 2007
  17. Jeff KingNov 28, 2007
  18. Junio C HamanoNov 28, 2007
  19. Steven GrimmNov 29, 2007
  20. Junio C HamanoNov 30, 2007
  21. Allow update hooks to update refs on their own.Steven Grimm, Dec 2, 2007
  22. Junio C HamanoDec 2, 2007
  23. Jeff KingDec 3, 2007
  24. Junio C HamanoDec 3, 2007
  25. Junio C HamanoDec 3, 2007
  26. Steven GrimmDec 5, 2007
  27. Junio C HamanoDec 5, 2007
  28. Junio C HamanoDec 5, 2007
  29. Jeff KingDec 6, 2007
  30. Junio C HamanoDec 6, 2007
  31. Jeff KingDec 6, 2007
  32. Steven GrimmDec 6, 2007
  33. Shawn O. PearceDec 3, 2007
  34. Junio C HamanoDec 3, 2007
  35. Shawn O. PearceDec 4, 2007
  36. Johannes SchindelinDec 3, 2007
  37. Shawn O. PearceDec 4, 2007
  38. Johannes SchindelinDec 4, 2007
  39. Shawn O. PearceDec 4, 2007
  40. Johannes SchindelinDec 4, 2007
  41. Steven GrimmDec 4, 2007
  42. Shawn O. PearceDec 4, 2007
  43. Junio C HamanoNov 28, 2007
  44. Jeff KingNov 28, 2007

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.