Re: [PATCH 5/6] builtin/repo: add disk size info to keyvalue stucture output
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Dec 10, 2025, 06:28 UTC
- Message-ID
- <aTkTCplQuSX_Y3oG@pks.im>
- In-Reply-To
- <20251209225820.2861276-6-jltobler@gmail.com>
On Tue, Dec 09, 2025 at 04:58:19PM -0600, Justin Tobler wrote:
Show 28 quoted lines
> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh > index 0ae96e6bbf..a98c651f1d 100755 > --- a/t/t1901-repo-structure.sh > +++ b/t/t1901-repo-structure.sh > @@ -35,6 +35,37 @@ test_expect_success 'empty repository' ' > git repo structure >out 2>err && > > test_cmp expect out && > + test_line_count = 0 err && > + > + cat >expect <<-\EOF && > + references.branches.count=0 > + references.tags.count=0 > + references.remotes.count=0 > + references.others.count=0 > + objects.commits.count=0 > + objects.trees.count=0 > + objects.blobs.count=0 > + objects.tags.count=0 > + objects.commits.inflated=0 > + objects.trees.inflated=0 > + objects.blobs.inflated=0 > + objects.tags.inflated=0 > + objects.commits.disk=0 > + objects.trees.disk=0 > + objects.blobs.disk=0 > + objects.tags.disk=0 > + EOF
Do we maybe want to adapt the keys to be "inflated_size" and "disk_size"?
Show 21 quoted lines
> @@ -106,16 +137,12 @@ test_expect_success SHA1 'keyvalue and nul format' ' > objects.tags.inflated=132 > EOF > > - git repo structure --format=keyvalue >out 2>err && > + git repo structure --format=keyvalue >out.raw 2>err && > > - test_cmp expect out && > - test_line_count = 0 err && > + # Strip object disk usage from output due to platform variance. > + grep -v "objects\..*\.disk=" out.raw >out && > > - # Replace key and value delimiters for nul format. > - tr "\n=" "\0\n" <expect >expect_nul && > - git repo structure --format=nul >out 2>err && > - > - test_cmp expect_nul out && > + test_cmp expect out && > test_line_count = 0 err > ) > '
We could test disk sizes here test if we use git-rev-list(1) to compute disk size by type:
git rev-list --disk-usage HEAD --objects --filter=object:type=blob
git rev-list --disk-usage HEAD --objects --filter=object:type=commit
git rev-list --disk-usage HEAD --objects --filter=object:type=tag
git rev-list --disk-usage HEAD --objects --filter=object:type=treeThe `--disk-usage` option also supports `--disk-usage=human`, which we can use in the next commit to verify that our computations are the same across git-rev-list(1) and git-repo(1).
Patrick