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

Re: Do porcelain command require lock management?

From
Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Date
Oct 26, 2020, 16:36 UTC
Message-ID
<20201026163643.6cp4jwj5lqkg6vns@chatter.i7.local>
In-Reply-To
<20201025230203.GH860779@camp.crustytoothpaste.net>
On Sun, Oct 25, 2020 at 11:02:03PM +0000, brian m. carlson wrote:
Show 23 quoted lines
> > A script I'm writing performs a succession of porcelain commands to
> > create a commit in a bare git repository:
> > 
> > git hash-object
> > git mktree
> > git commit-tree
> > git update-ref
> > 
> > Do I need to manage external locking around these commands to avoid any
> > concurrency problems, or will git take care of that?
> 
> I'm almost certain that Git will do the same locking and object creation
> semantics that it does in porcelain commands as in the plumbing commands
> you're using.  For example, I happen to know that all loose object
> creation goes through one function, which should gracefully handle
> concurrent accesses.  Git is in general safe against concurrent accesses
> and is designed not to lose or corrupt data in this case.
> 
> However, I will point out that ref updates may conflict and if so, Git
> will fail instead of waiting.  So while your repository will remain
> consistent and won't experience corruption, that doesn't mean that all
> operations will complete successfully.  Some sort of retry mechanism or
> other error handling will probably be warranted.

Thanks for your advice. I think in this case it's easier to just use simple locking to make sure that concurrent processes don't step on each-other's toes.

Best regards, -K

Previous: brian m. carlsonNext: Junio C Hamano
Message 3 of 4 in “Do porcelain command require lock management?”
  1. Konstantin RyabitsevOct 24, 2020
  2. brian m. carlsonOct 25, 2020
  3. Konstantin RyabitsevOct 26, 2020
  4. Junio C HamanoOct 26, 2020

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.