Skip to content

Forge push

Forge push

git push over SSH is served by forge since v0.1.0, which completes milestone 4 on the forge side. The receive-pack engine runs in the forge process: there is no git hook and no callback into the server. Source: go-vcs/forge, merged in #25 (wiring) and #26 (the engine).

forgectl ... repo add-collaborator alice/project bob
forgectl ... repo protect alice/project refs/heads/main
git push ssh://git@forge.example:2222/alice/project.git main

The owner and the collaborators may push; any other reader gets permission denied. HTTP stays anonymous and read-only, and answers a push with a message that names SSH.

What is refused

  • Protected refs. An exact name, or a prefix ending in /*, cannot be deleted or rewritten, only fast-forwarded. The branch HEAD points to cannot be deleted, and a branch must point to a commit.
  • Names that look like another ref. A new ref name that folds (case, Unicode form) to a protected or existing ref is refused. So is a name with a component ending in .lock (git holds refs/heads/main as main.lock while it updates it, and main.LOCK is that file on a case-insensitive file system), a name with a default-ignorable code point (U+200C, U+200D, U+FEFF and the like) and a name that is not ASCII. Deleting an existing ref of that kind stays allowed.
  • Other namespaces. Only refs/heads/* and refs/tags/* can be pushed.
  • Missing or hostile objects. Every object a new tip needs must be present (connectivity is checked in a quarantine, so a refused push leaves no object behind), a tree entry with a backslash in its name is refused, and git checks the received objects with --strict.

An atomic push applies all its commands or none. Each ref update is a compare-and-swap under a per-repository lock, so two pushes racing on one ref cannot both win.

Limits

All refused cleanly, with a message.

BoundDefault
commands per push100
ref name1 KiB
commands, in bytes1 MiB
pack size (--push-max-pack-bytes)512 MiB
objects per pack (--push-max-objects)1,000,000
inflated bytes per push, in total1 GiB
one object, or one delta result100 MiB
SSH connection lifetime1 hour

The 1 GiB is one byte budget per push: it charges every inflated byte, including the output of delta streams. The bases of a thin pack are charged too, twice their size (the bytes git inflates and the bytes it appends to the pack), measured in the repository before git unpacks anything; a pack that names a 16 MiB base under a 1 MiB budget is refused and the repository does not grow. At start the forge removes the stale ref lock files a killed git left behind.

Not done yet

The list comes from the PR body of #26.

  • No global cap across concurrent pushes. Each push is bounded, the sum is not: 64 pushes at a 4 MiB budget reached 910 MiB of RSS, and extrapolated to the defaults that is 15 to 22 GiB.
  • Flooding a push with thin-pack bases the repository lacks costs about 28 s of CPU per million ids.
  • A thin-pack base over 32 MiB is inflated again for each child.
  • The tree check has no deadline of its own, and a race between cat-file and index-pack remains.
  • The bench against git receive-pack is deferred.