Re: Modifying a bare repo directly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 11, 2017 at 10:35:17PM +0100, Julian Goacher wrote:

> Thanks for the replies; is there anything that needs to be known about
> concurrent updates on a repo when using plumbing commands?

Concurrent writes to the object database are always safe (so
hash-object, write-tree, commit-tree are fine). Updates to the index
will take a lock on the index; use a unique GIT_INDEX_FILE if you want
multiple independent updates to avoid conflicting with each other.

So all of that should be able to proceed independently. The place where
you might see conflicts is when you actually update the branch. The
locking there uses a "lease" system:

  1. At the start of the operation, you note that the branch is at some
     sha1 X.

  2. When you're ready to write, you feed update-ref the refname, the
     new sha1, and that original sha1.

  3. Update-ref takes a lock, checks that we are still at the old sha1,
     and then atomically writes the new sha1.

So if you have updates to multiple independent branches, they'll never
conflict. If you have multiple updates to the same branch, they may
race, but you'll never "lose" an update; each one will either succeed or
fail. Just make sure you pass the "old" sha1 to update-ref (the example
I posted did so).

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]