How locks are kept
How holding files works underneath, for a game on git.
The ref
Section titled “The ref”- A lock is one ref on the server,
refs/saturn/locks/<the SHA-1 of the file's path in lower case>, pointing at a commit with no files in it. The commit’s author and date are who took it and when. Its message is the path and aSaturn-Branchline naming the work that holds it. lockpushes that ref with--force-with-lease=<ref>:, which the server takes only while the ref does not exist, so two people cannot both win. Several locks go in one--atomicpush.unlockdeletes the ref with a lease on the commit it was seen to be.- Every verb’s fetch brings
refs/saturn/locks/*along and prunes the locks that were given back, so reading them costs no second trip to the server. - A lock’s commit also says which kind it is, in a
Saturn-Lockline.claimedis whatlockmakes.savedis whatsavemakes, after it has pushed the branch, and what it turns a claim into once the branch on the server changes the file.
Taking and giving back
Section titled “Taking and giving back”locklooks atmainonce before taking the lock and once after. A teammate who shipped the file in between is caught by the second look, and the lock is given back.savelets go of asavedlock of its own work when the work no longer changes the file.shiptakesclaimedlocks on what it changes before the checks, reads everyone’s locks then, and downloads them again just before the push tomain. A ship that opens a pull request turns its locks intosavedones once the branch is pushed.
Dead locks
Section titled “Dead locks”- A
savedlock is dead when its branch is gone from the server, or when merging that branch intomainwould no longer change the file.save,shipandlockdelete the dead locks they see, each with a lease on the commit it was seen to be.wholeaves them out and deletes nothing. Aclaimedlock is never dead, and neither is any lock in a folder that does not fetch every branch.
What counts as a file that cannot be combined
Section titled “What counts as a file that cannot be combined”- A file whose
mergesetting isbinaryor unset is one that cannot be combined, whoever said so: it is held like a model, and a clash over it is settled by picking a version. Nothing is givenlockable, which Git LFS’s hooks would take as a reason to make the file read-only.