diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-05-15 08:42:02 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-05-15 16:17:52 +0200 |
commit | e44b018c5299f2632fcbb079bead00a529546763 (patch) | |
tree | 285fe045daf583b3cd18bfa26e1398b643f83883 /t/t1300-config.sh | |
parent | builtin/config: move actions into `cmd_config_actions()` (diff) | |
download | git-e44b018c5299f2632fcbb079bead00a529546763.tar.xz git-e44b018c5299f2632fcbb079bead00a529546763.zip |
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>
Diffstat (limited to '')
-rwxr-xr-x | t/t1300-config.sh | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t1300-config.sh b/t/t1300-config.sh index d90a69b29f..9de2d95f06 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -2835,6 +2835,12 @@ test_expect_success 'specifying multiple modes causes failure' ' test_cmp expect err ' +test_expect_success 'writing to stdin is rejected' ' + echo "fatal: writing to stdin is not supported" >expect && + test_must_fail git config ${mode_set} --file - foo.bar baz 2>err && + test_cmp expect err +' + done test_done |