Read blobs in process with go-git - #3
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR replaces per-blob git show subprocess reads with in-process blob reads via go-git’s filesystem object store, while keeping the existing Blob and InspectBlob APIs and retaining a native-git fallback for unsupported repository formats/layouts.
Changes:
- Added a go-git–backed object-store reader to resolve commits/tags and stream blob contents with a max-byte cap.
- Updated blob read path to prefer go-git, falling back to
git showfor compatibility. - Expanded documentation and tests to cover packed objects, linked worktrees, bare repos, annotated tags, cancellation, and SHA-256 fallback behavior.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates user-facing docs to describe in-process blob reads and fallback behavior. |
| object_store.go | Introduces go-git filesystem storage access and object-resolution logic used for blob reads. |
| go.mod | Adds go-git/go-billy dependencies (plus indirects) needed for in-process reads. |
| go.sum | Records checksums for the newly added module dependencies. |
| doc.go | Updates package docs to reflect mixed go-git (blobs) + native git (network/other ops) behavior. |
| blob.go | Switches blob reading to go-git-first with native-git fallback; adds context-aware reader wrapper. |
| blob_test.go | Adds test coverage for new repository formats/layouts and PATH-less operation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the per-blob
git showsubprocess with bounded go-git object reads while keeping the existingBlobandInspectBlobAPIs. The implementation uses the filesystem object store directly and streams packed blobs larger than the requested limit. Native Git remains the compatibility path for unsupported repository formats and layouts, including SHA-256 repositories with full or abbreviated object IDs.Scrutineer consumer benchmarks on an Apple M1 Pro show a 4.8 KB sequential read dropping from 7.65 ms to 0.239 ms, about 32 times faster. The parallel result drops from 1.48 ms to 0.0816 ms. A packed 3 MB blob capped at 2 MB drops from 11.79 ms to 2.43 ms sequentially and from 2.83 ms to 0.561 ms in parallel. Memory allocated for that large read falls from 4.72 MB to 2.23 MB.
The stripped Scrutineer binary increases by about 615 KB, or 2.5 percent. Gzip-compressed, the increase is about 219 KB, or 2.4 percent. The change also covers packed objects, linked worktrees, bare repositories, nested paths, annotated tags, abbreviated SHA-1 IDs, cancellation, and operation without
gitonPATHfor the in-process path.