How geoffgarside/git.framework works
1. This repo is a Cocoa/Foundation framework, not an app: Git.framework provides an Objective-C API for reading and partially writing Git repositories on macOS (and potentially iPhone OS). The core boundary is the local .git directory on disk; most subsystems translate repository files and binary formats into Objective-C objects.
2. The top-level API surface lives in Source/Git.h and the GIT* classes. These model Git concepts directly: repository, refs, branches, commits, tags, trees, blobs, objects, pack files, pack indexes, graphs, and revision enumeration. The architecture is object-centric, with each Git storage format wrapped by a corresponding Cocoa class.
3. GITRepo is the main orchestration entry point. It ties together object lookup, ref resolution, and commit/history traversal. From an architecture perspective, it is the façade that other code would use to open a repository and ask for branches, objects, or revision lists.
4. Object storage is split into two paths: loose objects and packed objects. GITLooseObject handles individual object files, while GITPackCollection, GITPackFile, GITPackIndex, GITPackObject, and the related placeholder/versioned classes handle .pack and .idx data. This is a major boundary in the design because Git reads must transparently resolve an object from either storage mechanism.
5. Binary parsing is a dedicated layer. Source/GITObject+Parsing, GITCommit+Parsing, GITActor+Parsing, and GITTreeItem-related code translate raw Git data into strongly typed model objects. The data flow is: disk bytes → parsed Git object → domain object (commit/tree/blob/tag).
6. Ref handling is isolated from object storage. GITRef, GITBranch, GITRefResolver, and GITPackedRefsEnumerator cover .git/refs and packed refs, allowing the framework to map symbolic names to object hashes and then to actual objects. This boundary matters because refs are the indirection layer between branch names and commit objects.
7. History traversal is represented by GITCommitEnumerator, GITRevList, GITGraph, and GITGraphNode. These classes build and walk commit graphs in breadth-first or depth-first order and support a subset of git rev-list. The history subsystem sits on top of object parsing and ref resolution, not beside them.
8. Data types used throughout the framework have small utility extensions under Source/Category. There are NSData categories for CRC32, compression, delta patching, SHA1, and searching; NSRange and NSTimeZone categories support parsing and time handling. These are low-level helpers that enable Git’s binary formats and timestamp semantics without adding separate subsystems.
9. The pack-writing side exists but is clearly less mature than reading. GITPackFileWriter, GITPackIndexWriter, and the versioned placeholder classes indicate support for generating pack/index files, but the README notes deltas are unsupported and the API still needs work. So the architecture includes a write pipeline, but read paths are the primary production feature.
10. The repository includes BridgeSupport metadata in Resource/BridgeSupport/Git.bridgesupport, which exposes C-level symbols to bridged runtimes such as MacRuby or PyObjC. This is an interoperability boundary: the framework is intended to be used not only from Objective-C, but also from other Cocoa-compatible languages.
11. Build, packaging, and docs are part of the repo’s delivery architecture. The Xcode project builds the framework; Rakefile automates builds, tab checks, and BridgeSupport generation; Documentation/doxyclean and the Graffle doc assets support generated API docs. Resource/Info.plist and version files define framework metadata and versioning.
12. Tests are organized as a Ruby/MacRuby-based suite under Test/Unit, with helpers in Test/Support. That tells you the validation layer is external to the Objective-C runtime itself and likely exercises the framework from a bridged scripting environment, which is useful for verifying parsing and repository behavior against real Git data.
13. In diagram form, the main flow is: repository filesystem data → refs and pack/loose object readers → parsers/model objects → traversal/graph/rev-list services → client API through GITRepo and related classes. The key architectural distinction is between storage-format adapters at the bottom and Git-domain abstractions at the top.
Main entry points: GITRepo.h Repo · GITCommit.h Commit · GITPackCollection.h Pack collection · GITGraph.h History graph
Components 23
Core framework
Public Git domain API and repository orchestration.
- Git API · Top-level framework header that exposes the Objective-C surface.
Source/Git.h - Repo · Main entry point for opening repositories and coordinating lookup and traversal.
Source/GITRepo.h - Git object · Base object abstraction for commits, trees, blobs, and tags.
Source/GITObject.h - Commit · Commit object wrapper with parent and message semantics.
Source/GITCommit.h - Tree · Tree object wrapper for directory structure in the repository.
Source/GITTree.h - Blob · Blob object wrapper for file contents.
Source/GITBlob.h - Tag · Annotated tag object wrapper.
Source/GITTag.h - History graph · Builds commit graphs for traversal and revision listing.
Source/GITGraph.h - Rev list · Implements revision enumeration and history selection over commits.
Source/GITRevList.h - Commit enum · Walks commit history in a chosen order.
Source/GITCommitEnumerator.h
Storage layer
On-disk object, ref, and packfile adapters.
- Ref · Represents branch and reference names that point to object hashes.
Source/GITRef.h - Branch · Branch-specific ref abstraction layered on top of repository references.
Source/GITBranch.h - Packed refs · Enumerates refs stored in packed-refs form.
Source/GITPackedRefsEnumerator.h - Loose object · Reads individual Git objects from loose files in .git/objects.
Source/GITLooseObject.h - Pack collection · Finds and coordinates packed objects across pack files and indexes.
Source/GITPackCollection.h - Pack file · Reads .pack data and resolves packed objects.
Source/GITPackFile.h - Pack index · Reads .idx files to locate packed objects inside pack files.
Source/GITPackIndex.h
Support code
Parsing helpers and low-level Foundation categories.
- Parsing · Transforms raw Git bytes into typed model objects.
Source/GITObject+Parsing.h - Actor parse · Parses author and committer identity records.
Source/GITActor+Parsing.h - Foundation cats · NSData, NSRange, and NSTimeZone helpers for Git-specific binary and time handling.
Source/Category
Delivery
Build, packaging, docs, bridging, and tests.
- BridgeSupport · Exposes framework symbols to bridged runtimes such as Ruby-based Cocoa environments.
Resource/BridgeSupport/Git.bridgesupport - Build & docs · Xcode project, Rake automation, version metadata, and documentation assets.
Git.xcodeproj/project.pbxproj - Tests · MacRuby/Ruby-based validation suite for repository behavior and parsing.
Test/Unit
Connections 24
- Git API → Repo: exports · The umbrella header exposes the main repository API.
- Repo → Ref: resolves · Repository lookup starts by resolving names to refs.
- Repo → Branch: lists · Branches are derived from repository refs.
- Repo → Loose object: reads · Repository access may load loose objects directly.
- Repo → Pack collection: reads · Repository access also resolves objects through packs.
- Packed refs → Ref: yields · Packed refs are turned into reference objects.
- Pack collection → Pack file: coordinates · The collection manages pack files as a set.
- Pack collection → Pack index: coordinates · The collection pairs packs with their indexes.
- Pack index → Pack file: locates · Indexes provide offsets into pack files.
- Loose object → Git object: materializes · Loose object bytes become Git domain objects.
- Pack file → Git object: materializes · Packed object bytes become Git domain objects.
- Parsing → Git object: parses · Raw object data is converted into typed objects.
- Actor parse → Commit: supports · Commit parsing depends on parsed actor metadata.
- Commit → Tree: references · Commits point to tree snapshots.
- Tree → Blob: contains · Trees contain blob entries and subtrees.
- Commit → Tag: reachable via · Tags can reference commits and other objects.
- Commit enum → History graph: walks · Commit enumeration builds on the history graph.
- Rev list → History graph: queries · Revision listing uses graph structure for traversal.
- History graph → Commit: navigates · The history graph traverses commits and their parents.
- Foundation cats → Parsing: enables · Utility categories support checksum, compression, time, and range parsing.
- BridgeSupport → Git API: bridges · BridgeSupport exposes the framework API to other runtimes.
- Build & docs → BridgeSupport: generates · Build and packaging steps include bridge metadata and documentation assets.
- Tests → Repo: exercises · The test suite drives repository-level behavior.
- Tests → Parsing: verifies · Tests validate parsing and object conversion paths.