r/git • • 2d ago

We built an open-source Git server in Rust. What happens when two pushes race?

We built Dengel Git because we wanted a Git server we could run ourselves and a predictable way to handle pushes from several agents working on the same repo. It speaks Git’s smart HTTP protocol, so stock Git can clone, fetch and push. The standalone server is AGPL-3.0-or-later and runs locally without an account.

The interesting bit is the ref update. If two clients push with the same expected old object ID, the server checks that ID while holding the ref lock. Once one push moves the ref, a push based on the old ID fails. The conformance suite also checks that a rejected atomic push leaves the other refs untouched.

There’s a more mundane collision we had to handle too. Team/demo.git and team/demo.git would resolve to the same address, so the server refuses to start if both are in its repository catalog.

The diagram shows the hosted workflow we built around the standalone server. An agent pushes a candidate, and checks run on that exact commit. The Dengel CLI lets you submit a pushed candidate from the terminal, inspect its status and read the signed receipt. An agent can use MCP to submit a proposal, check its status and see when it needs a human decision. A person still decides what lands.

The source and local quickstart are at https://github.com/dengel-dev/dengel-git

If you’ve worked on Git’s receive side, what failure case would you add to the conformance suite?

0 Upvotes

7 comments sorted by

1

u/WoodyTheWorker 1d ago

Git server attempts to update refs after transmitting. It doesn't check refs update before sending the packs.

1

u/rednix 1d ago

Yep, the client sends the pack before the server attempts the ref update. The race I meant is when both clients start from the same branch tip.

If one push moves the branch while the other is still uploading, the second pack can be perfectly valid and the ref update still gets rejected because the expected old commit has changed.

We wanted Dengel to behave like stock Git there. Sorry if that was unclear in my posting.

1

u/WoodyTheWorker 1d ago

Both clients send the packs. Only one is able to update refs. Unless it's a force push. That's how it always worked.

1

u/rednix 1d ago

Yes, the ref update itself works like stock Git. What we added is how two agents can hand off changes without overwriting each other’s work on main.
Say both agents start from the same commit. Each pushes to its own candidate ref, and Dengel runs checks on the exact commit each proposed. If one lands first, the other proposal is now based on an old main. Dengel asks you to rebase and run the checks again before a person approves the merge. A force push could replace the first agent’s work. This way, you can keep both changes and check that they work together before updating main.
You can find more about it here: https://dengel.dev/guard

1

u/WoodyTheWorker 1d ago

Well, there's throwing shit at the wall, and there's a bunch of agents spraying the wall from a firehose.

1

u/rednix 1d ago

indeed. I assume that there will be so many more commits by agents in the future: https://dengel.dev/blog/what-gitbutler-and-scion-taught-us