Subject: Re: [PATCH v3 0/4] breaking changes: switch default initial branch name to "main"

From: Phillip Wood <[email-masked]>
Date: Thu, 18 Sep 2025 16:06:44 +0100

On 17/09/2025 17:16, Junio C Hamano wrote:
> Junio C Hamano <[email-masked]> writes:
> 
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index df0040b9ac..c7f39248e0 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -562,9 +562,9 @@ test_expect_success 'init warns about invalid init.defaultObjectFormat' '
>   	test_when_finished "rm -rf repo" &&
>   	test_config_global init.defaultObjectFormat garbage &&
>   
> -	echo "warning: unknown hash algorithm ${SQ}garbage${SQ}" >expect &&
> +	expect="warning: unknown hash algorithm ${SQ}garbage${SQ}" &&
>   	git init repo 2>err &&
> -	test_cmp expect err &&
> +	test_grep "$expect" err &&
>   
>   	git -C repo rev-parse --show-object-format >actual &&
>   	echo $GIT_DEFAULT_HASH >expected &&
> 
> I think in the longer run, a change like this that makes us check
> only what we care about (i.e., "do we warn about unknown hash
> algo?"), without assuming more than necessary (i.e., "we shouldn't
> get any other warnings or hints, or this check with test_cmp that
> expects an exact match will fail), is a good thing.
> 
> Perhaps a #leftoverbit material.

I could go either way on this. If we want to test to be focused on the 
error message when git encounters an unknown hash algorithm then I agree 
using test_grep is an improvement over test_cmp. On the other hand it is 
a bit weird if we start showing hints about the default branch name when 
the hash algorithm is invalid and so we cannot initialize the repository 
so maybe detecting that is useful.

Thanks

Phillip