Subject: Re: [PATCH v2 4/5] setup: make object format configurable via config

From: Junio C Hamano <[email-masked]>
Date: Fri, 16 Aug 2024 10:13:07 -0700

Patrick Steinhardt <[email-masked]> writes:

> The precedence order now is the following, where the first one wins:
>
>   1. The `--object-format=` switch.
>
>   2. The `GIT_DEFAULT_HASH` environment variable.
>
>   3. The `init.defaultObjectFormat` config variable.
>
> This matches the typical precedence order we use in Git. We typically
> let the environment override the config such that the latter can easily
> be overridden on an ephemeral basis, for example by scripts.

Thanks for documenting this, as the reason for deciding the
precedence between environment and configuration is no longer as
strong as it used to be.

Before the "git -c var=val" happened, the only sensible preference
order was to allow environment to override a configured default by
doing "VAR=val git cmd ...".  In other words, the order used to be
something you could safely forget and still infer the right order
with logic alone.

But with "git -c var=val", even if a hypothetical Git allowed
configuration to override environment, a user could still override
them with "-c var=val", so "environment trumps configuration" is no
longer "because there is no sensible workaround if it were the other
way around", but merely "because that used to be the only logical
way".