Skip to content

Read blobs in process with go-git - #3

Merged
andrew merged 3 commits into
mainfrom
go-git-blob-inspection
Aug 10, 2026
Merged

Read blobs in process with go-git#3
andrew merged 3 commits into
mainfrom
go-git-blob-inspection

Conversation

@andrew

@andrew andrew commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Replace the per-blob git show subprocess with bounded go-git object reads while keeping the existing Blob and InspectBlob APIs. 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 git on PATH for the in-process path.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 show for 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.

Comment thread object_store.go
Comment thread blob.go Outdated
@andrew
andrew merged commit 4c2620f into main Aug 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants