GeezerVison is showing github.com — Add --include-unreachable flag and related processing by ScottArbeit · Pull Request #141 · github/git-sizer
Conversation
ScottArbeit
commented
Apr 16, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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:
- A new command-line flag
--include-unreachable so that the new functionality only runs when requested
- Processing of each unreachable object using
git cat-file --batch-check
- Output of the count and uncompressed total size of unreachable objects in a new section in the output
Considerations
Getting the uncompressed size of the unreachable objects means listing them and then running git cat-file --batch-check with each unreachable oid input to stdin. 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):
(5:53:24 PM) D:\Source\Grace>D:\Source\github\git-sizer\bin\git-sizer.exe -v --include-unreachable
Processing blobs: 2593
Processing trees: 1427
Processing commits: 207
Matching commits to trees: 207
Processing annotated tags: 1
Processing references: 7
| Name | Value | Level of concern |
| ---------------------------- | --------- | ------------------------------ |
| Repository statistics | | |
| * Commits | | |
| * Count | 207 | |
| * Total size | 72.4 KiB | |
| * Trees | | |
| * Count | 1.43 k | |
| * Total size | 777 KiB | |
| * Total tree entries | 18.1 k | |
| * Blobs | | |
| * Count | 2.59 k | |
| * Uncompressed total size | 57.4 MiB | |
| * On-disk size | | |
| * Compressed total size | 2.74 MiB | |
| * Annotated tags | | |
| * Count | 1 | |
| * References | | |
| * Count | 7 | |
| * Branches | 3 | |
| * Tags | 1 | |
| * Remote-tracking refs | 3 | |
| | | |
| Biggest objects | | |
| * Commits | | |
| * Maximum size [1] | 1.51 KiB | |
| * Maximum parents [2] | 2 | |
| * Trees | | |
| * Maximum entries [3] | 41 | |
| * Blobs | | |
| * Maximum size [4] | 946 KiB | |
| | | |
| History structure | | |
| * Maximum history depth | 197 | |
| * Maximum tag depth [5] | 1 | |
| | | |
| Biggest checkouts | | |
| * Number of directories [6] | 55 | |
| * Maximum path depth [6] | 7 | |
| * Maximum path length [6] | 72 B | |
| * Number of files [6] | 258 | |
| * Total size of files [6] | 4.28 MiB | |
| * Number of symlinks | 0 | |
| * Number of submodules | 0 | |
| | | |
| Unreachable objects | | | <--- new output section
| * Blobs | | |
| * Count | 21 | |
| * Uncompressed total size | 428 KiB | |
| * Trees | | |
| * Count | 30 | |
| * Total size | 22.1 KiB | |
| * Commits | | |
| * Count | 18 | |
| * Total size | 5.30 KiB | |
| * Tags | | |
| * Count | 0 | |
| * Total size | 0 B | |
_detailed refs redacted_
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 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
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
At least 1 approving review is required to merge this pull request.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.