How chrislloyd/git-remote-sqlite works
Purpose and Invocation
git-remote-sqlite is a Zig-built Git remote helper that maps Git fetch/push operations onto a SQLite database. Git invokes the installed git-remote-sqlite executable for sqlite://… remotes; the same binary also exposes direct database configuration commands. Primary entry and command dispatch are in src/main.zig, src/cli.zig, and src/cmd.zig.
Git Remote-Helper Protocol Boundary
The helper communicates with Git through the standard remote-helper line protocol over stdin/stdout. Protocol parsing, command negotiation, and responses form the main compatibility boundary with Git. src/protocol.zig defines this protocol-facing behavior, while src/transport.zig implements object/ref transfer mechanics and src/help.zig supports command-facing help behavior.
Repository Storage Model
Git’s content-addressed objects and references are persisted as SQLite rows rather than loose objects or pack files. The documented persistent model centers on Git objects, direct refs, and symbolic refs. SQLite access and schema-oriented persistence belong in src/sqlite.zig; the durable schema contract is documented in docs/schema.md.
Push and Fetch Data Flow
For a push, Git negotiates commands with the helper, which resolves the SQLite remote, receives or reads Git objects, writes object records, and updates refs. For pull/fetch, it reads refs and objects from SQLite and streams the requested Git data back through the helper protocol. The cross-cutting Git object/ref representation is handled by src/git.zig; remote location handling is in src/remote.zig; transfer orchestration spans src/transport.zig and src/protocol.zig.
Remote and Configuration Handling
SQLite remotes are addressed through sqlite:// URLs and database paths. The CLI also supports server-side-style configuration CRUD stored with the repository, although the README states those settings do not yet alter behavior. URL/database resolution is isolated in src/remote.zig; configuration persistence and commands are represented by src/config.zig and src/cmd.zig.
Runtime and External Dependencies
The shipped artifact is a native Zig executable, built from build.zig with package metadata in build.zig.zon. Runtime interoperability depends on Git (remote-helper protocol) and SQLite (database engine and file format). The design intentionally leaves authentication and authorization outside the helper; deployments needing replication may pair the SQLite file with external tools such as Litestream and storage services such as S3.
Operational Constraints
This is a local/trusted-environment storage backend rather than a Git forge or network server. It currently favors simple object-row storage over pack-file efficiency, so large repositories and clones may have performance limits. Planned architecture extensions include pack management, Git hooks, and broader protocol command coverage; these concerns attach primarily to src/sqlite.zig, src/transport.zig, and src/protocol.zig.
Main entry points: sqlite.zig SQLite persistence · protocol.zig Remote-helper protocol · cmd.zig Command dispatch · transport.zig Transfer orchestration
Components 13
Runtime
- Git client · Invokes the helper for sqlite:// remotes.
- Zig build · Builds the native helper executable.
build.zig
Remote helper
- Executable entry
src/main.zig - CLI parsing
src/cli.zig - Command dispatch · Routes helper and direct configuration commands.
src/cmd.zig - Remote-helper protocol · Parses and responds on stdin/stdout.
src/protocol.zig - Transfer orchestration · Moves requested objects and refs in both directions.
src/transport.zig - Remote resolution · Resolves sqlite:// URLs and database paths.
src/remote.zig
SQLite storage
- Git objects and refs · Represents content-addressed objects, direct refs, and symbolic refs.
src/git.zig - SQLite persistence · Reads and writes object, ref, and configuration rows.
src/sqlite.zig - Repository configuration · Stores configuration CRUD data; settings do not yet alter behavior.
src/config.zig - SQLite database file · Persistent backend for Git objects and refs.
- Schema contract · Documents durable object and ref tables.
docs/schema.md
Connections 16
- Zig build → Executable entry: builds
- Git client → Executable entry: invokes
- Executable entry → CLI parsing: starts
- CLI parsing → Command dispatch: parses commands
- Command dispatch → Remote-helper protocol: remote-helper mode
- Command dispatch → Repository configuration: configuration CRUD
- Remote-helper protocol → Git client: line protocol
- Remote-helper protocol → Transfer orchestration: negotiates transfer
- Remote-helper protocol → Remote resolution: resolves remote
- Transfer orchestration → Git objects and refs: reads and writes
- Transfer orchestration → SQLite persistence: fetches and pushes
- Remote resolution → SQLite persistence: opens database
- Git objects and refs → SQLite persistence: persisted as rows
- Repository configuration → SQLite persistence: stores settings
- SQLite persistence → SQLite database file: SQLite access
- Schema contract → SQLite database file: documents