git-sizer icon indicating copy to clipboard operation
git-sizer copied to clipboard

Add --include-unreachable flag and related processing

Open ScottArbeit opened this issue 8 months ago • 0 comments

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_

ScottArbeit avatar Apr 16 '25 01:04 ScottArbeit