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

Re: Do porcelain command require lock management?

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Oct 25, 2020, 23:02 UTC
Message-ID
<20201025230203.GH860779@camp.crustytoothpaste.net>
In-Reply-To
<20201024144637.cvwa22f2y4tvfn4z@chatter.i7.local>
On 2020-10-24 at 14:46:37, Konstantin Ryabitsev wrote:
Show 12 quoted lines
> Hello:
> 
> 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.

-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US
Previous: Konstantin RyabitsevNext: Konstantin Ryabitsev
Message 2 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.