Add --include-unreachable flag and related processing#141
Open
ScottArbeit wants to merge 14 commits intogithub:masterfrom
Open
Add --include-unreachable flag and related processing#141ScottArbeit wants to merge 14 commits intogithub:masterfrom
ScottArbeit wants to merge 14 commits intogithub:masterfrom
Conversation
added 9 commits
March 31, 2025 23:55
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new flag, --include-unreachable, to optionally include unreachable objects when reporting repository statistics. Key changes include adding new fields for unreachable objects and .git directory size in the statistics structure, updating output formatting to display these new values, and implementing the processing logic (via git fsck and git cat‐file batch mode) to compute unreachable object stats.
Reviewed Changes
Copilot reviewed 6 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sizes/sizes.go | Added new fields to HistorySize for unreachable object stats and the .git directory size. |
| sizes/output.go | Updated repository statistics output with a new section for unreachable objects and on-disk size. |
| sizes/dirsize.go | Introduced a helper function to calculate the size of the .git directory. |
| git/git.go | Added GetUnreachableStats and helper function to compute unreachable objects’ total size. |
| git-sizer.go | Added --include-unreachable flag and integrated unreachable stats processing. |
| CONTRIBUTING.md | Updated dependency installation instructions for Unix and Windows environments. |
Files not reviewed (4)
- Makefile.win: Language not supported
- script/bootstrap.ps1: Language not supported
- script/ensure-go-installed.ps1: Language not supported
- script/go.ps1: Language not supported
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…eit/git-sizer into Add-unreachable-objects
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.
This PR adds a new flag to git-sizer,
--include-unreachable, to include unreachable objects in the counts displayed in the output.Changes
It adds the following:
--include-unreachableso that the new functionality only runs when requestedgit cat-file --batch-checkConsiderations
Getting the uncompressed size of the unreachable objects means listing them and then running
git cat-file --batch-checkwith each unreachable oid input tostdin. This is, obviously, an O(n) operation, and that's why I've stuck it behind a new flag rather than including it in processing by default.For repos with a lot of unreachable objects, this will take some time to run.
Sample output
Here's an example of the output including the new section (at the bottom):