Re: [PATCH 5/6] builtin/repo: add disk size info to keyvalue stucture output
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Dec 10, 2025, 15:24 UTC
- Message-ID
- <zq7iwyz6jhhj4bf5th2dwoe3ldtmtxeqqgrhx2mc4dgiaujzaa@frsaxmwmdzps>
- In-Reply-To
- <aTkTCplQuSX_Y3oG@pks.im>
On 25/12/10 07:28AM, Patrick Steinhardt wrote:
Show 32 quoted lines
> On Tue, Dec 09, 2025 at 04:58:19PM -0600, Justin Tobler wrote: > > 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"?
Good suggestion. I'll update in the next version.
Show 33 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=tree > > The `--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).
Thanks! I hadn't considered this. I'll try to update the tests in the next version using this.
-Justin