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

Re: [SCRIPT] cg-rpush & locking

From
Linus Torvalds <torvalds@osdl.org>
Date
Jun 2, 2005, 02:58 UTC
Message-ID
<Pine.LNX.4.58.0506011951150.1876@ppc970.osdl.org>
In-Reply-To
<20050601065123.GA23358@cip.informatik.uni-erlangen.de>
On Wed, 1 Jun 2005, Thomas Glanzmann wrote:
Show 8 quoted lines
> 
> 	1. acquire remote lock
> 	2. get remote HEAD
> 	3. if remote HEAD is ahead (not included in our history) abort
> 	   and free lock.
> 	4. push objects
> 	5. update remote HEAD with local
> 	6. free remote lock.

You really need a specialized client at the other end, because regardless of locking, you want to write the objects atomically (ie download them into a temp-file, and then do the "rename" thing to make them show up all-or-nothing).

Also, I'd suggest a slight modification to avoid keeping the lock for a long time, namely to have the lock protect just a quick "compare and exchange". So the algorithm would become:

	1. read remote HEAD
	2. if remote HEAD isn't in our history, abort with "remote is 
	   ahead"
	3. calculate the objects needed to push locally
	4. push them (but accept the possibility that the remote may
	   already have them, so have the protocol able to say "got that
	   one already"). Make this use the atomic write on the other end.
	5. do an atomic compare-and-exchange of the remote head with the 
	   new one (ie only switch the remote HEAD if it still matches 
	   what we were expecting it to be)
Hmm?
		Linus
Previous: Tony LindgrenNext: Daniel Barkalow
Message 5 of 13 in “[SCRIPT] cg-rpush & locking”
  1. Tony LindgrenMay 31, 2005
  2. Nicolas PitreMay 31, 2005
  3. Thomas GlanzmannJun 1, 2005
  4. Tony LindgrenJun 1, 2005
  5. Linus TorvaldsJun 2, 2005
  6. Daniel BarkalowJun 2, 2005
  7. Matthias UrlichsJun 2, 2005
  8. Tony LindgrenJun 2, 2005
  9. Matthias UrlichsJun 2, 2005
  10. Linus TorvaldsJun 2, 2005
  11. Tony LindgrenJun 2, 2005
  12. Daniel BarkalowJun 2, 2005
  13. Dan HolmsandJun 2, 2005

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.