builtin/config: check for writeability after source is set up
commite44b018c5299f2632fcbb079bead00a529546763
authorPatrick Steinhardt <ps@pks.im>
Wed, 15 May 2024 06:42:02 +0000 (15 08:42 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 May 2024 14:17:52 +0000 (15 07:17 -0700)
tree285fe045daf583b3cd18bfa26e1398b643f83883
parent9cab5e8078c314957395ddb4c198c3320c4e5a91
builtin/config: check for writeability after source is set up

The `check_write()` function verifies that we do not try to write to a
config source that cannot be written to, like for example stdin. But
while the new subcommands do call this function, they do so before
calling `handle_config_location()`. Consequently, we only end up
checking the default config location for writeability, not the location
that was actually specified by the caller of git-config(1).

Fix this by calling `check_write()` after `handle_config_location()`. We
will further clarify the relationship between those two functions in a
subsequent commit where we remove the global state that both implicitly
rely on.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/config.c
t/t1300-config.sh