Subject: Re: [PATCH v3 7/7] builtin/repo: add object disk size info to structure table

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 16 Dec 2025 09:25:30 +0100

On Mon, Dec 15, 2025 at 02:56:39PM -0600, Justin Tobler wrote:
> diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
> index dd17caad05..64db191234 100755
> --- a/t/t1901-repo-structure.sh
> +++ b/t/t1901-repo-structure.sh
> @@ -5,8 +5,18 @@ test_description='test git repo structure'
>  . ./test-lib.sh
>  
>  object_type_disk_usage() {
> -	git rev-list --all --objects --disk-usage --filter=object:type=$1 \
> -		--filter-provided-objects
> +	disk_usage_opt="--disk-usage"
> +
> +	if [ "$2" = "true" ]; then
> +		disk_usage_opt="--disk-usage=human"
> +	fi
> +
> +	if [ "$1" = "all" ]; then
> +		git rev-list --all --objects $disk_usage_opt
> +	else
> +		git rev-list --all --objects $disk_usage_opt \
> +			--filter=object:type=$1 --filter-provided-objects
> +	fi
>  }
>  
>  test_expect_success 'empty repository' '

We don't use `if [ ... ]` in our codebase, and we typically have the
`then` on the next line:

    if test "$2" = "true"
    then
        ...
    fi

    if test "$1" = "all"
    then
        ...
    else
        ...
    fi

> @@ -79,6 +94,11 @@ test_expect_success SHA1 'repository with references and objects' '
>  		|     * Trees          |  15.81 MiB |
>  		|     * Blobs          |  11.68 KiB |
>  		|     * Tags           |    132 B   |
> +		|   * Disk size        | $(object_type_disk_usage all true) |
> +		|     * Commits        | $(object_type_disk_usage commit true) |
> +		|     * Trees          | $(object_type_disk_usage tree true) |
> +		|     * Blobs          |  $(object_type_disk_usage blob true) |
> +		|     * Tags           |    $(object_type_disk_usage tag) B   |
>  		EOF

Curious, but why is the last one special here?

Patrick