Skip to content

How locks are kept

How holding files works underneath, for a game on git.

  • 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 a Saturn-Branch line naming the work that holds it.
  • lock pushes 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 --atomic push. unlock deletes 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-Lock line. claimed is what lock makes. saved is what save makes, after it has pushed the branch, and what it turns a claim into once the branch on the server changes the file.
  • lock looks at main once 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.
  • save lets go of a saved lock of its own work when the work no longer changes the file.
  • ship takes claimed locks on what it changes before the checks, reads everyone’s locks then, and downloads them again just before the push to main. A ship that opens a pull request turns its locks into saved ones once the branch is pushed.
  • A saved lock is dead when its branch is gone from the server, or when merging that branch into main would no longer change the file. save, ship and lock delete the dead locks they see, each with a lease on the commit it was seen to be. who leaves them out and deletes nothing. A claimed lock 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 merge setting is binary or 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 given lockable, which Git LFS’s hooks would take as a reason to make the file read-only.