Pure Pony Git Client for Corral #307
SeanTAllen
started this conversation in
Git for Corral
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Motivation
Corral currently shells out to the
gitCLI viaProcessMonitorfor all git operations. Replacing this with a pure Pony implementation removes the runtime dependency ongitbeing installed, which matters for a package manager:Replacing
gitwith FFI bindings to libgit2, zlib, or OpenSSL would just trade one external dependency for others. The goal is a fully self-contained implementation. The one accepted external dependency is SSL (via LibreSSL/OpenSSL) for HTTPS transport — this can be statically linked on all platforms (LibreSSL on macOS/Windows, musl builds on Linux).Current Git Usage in Corral
Corral uses exactly 5 git commands (all in
corral/vcs/git.pony), all read-only:git clone --no-checkout https://... pathgit -C path fetch --tagsgit -C path show-refgit -C path reset --mixed revgit -C path checkout-index -f -a --prefix=path/The flow: clone/fetch a repo -> list tags -> resolve version constraints -> reset to chosen revision -> export files to workspace. Corral is strictly a consumer of git data, never a producer.
Implementation Components
1. Pure Pony SHA-1
Effort: Small (~100-200 lines)
Well-specified algorithm, just bitwise operations on U32 values. Performance is adequate for corral's use case (hashing individual git objects, not bulk data). The spec is ~10 pages with no ambiguity. There may be an existing implementation in ponylang/ssl that could be reused.
2. Pure Pony Inflate (zlib decompression)
Effort: Medium-large (~800-1,200 lines)
The biggest foundational piece. Git uses zlib to compress every object. Corral only reads git data, so only inflate (decompression) is needed, not deflate.
Sub-components:
Reference points: miniz's
tinfl_decompressis ~500 lines of dense C with heavy macros. Go'scompress/flatereader is ~800 lines. Pony would likely land in a similar range. Well-specified by RFC 1951 with no ambiguity.3. Git Smart HTTP Protocol
Effort: Medium
Layered on top of vendored ponylang/courier HTTP client library:
/info/refs?service=git-upload-packcapability advertisementCourier and its dependency tree will be vendored into the corral repo so that corral does not require itself to bootstrap.
4. Packfile Parser
Effort: Medium-large
The most complex git-specific binary format:
5. Git Object Database and Ref Management
Effort: Medium, well-documented formats
.git/objects/xx/yyyy...files.idx) files for object lookup in packfiles.git/refs/tags/*files +.git/packed-refsparsing6. Index and Tree Operations
Effort: Medium
Estimates
A real project but not an unreasonable one, especially since corral only needs the read side of git.
All reactions