Merge branch 'mt/config-fail-nongit-early'
Unlike "git config --local", "git config --worktree" did not fail early and cleanly when started outside a git repository. * mt/config-fail-nongit-early: config: complain about --worktree outside of a git repo
This commit is contained in:
@ -628,11 +628,15 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||||||
usage_builtin_config();
|
usage_builtin_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_local_config && nongit)
|
if (nongit) {
|
||||||
die(_("--local can only be used inside a git repository"));
|
if (use_local_config)
|
||||||
|
die(_("--local can only be used inside a git repository"));
|
||||||
|
if (given_config_source.blob)
|
||||||
|
die(_("--blob can only be used inside a git repository"));
|
||||||
|
if (use_worktree_config)
|
||||||
|
die(_("--worktree can only be used inside a git repository"));
|
||||||
|
|
||||||
if (given_config_source.blob && nongit)
|
}
|
||||||
die(_("--blob can only be used inside a git repository"));
|
|
||||||
|
|
||||||
if (given_config_source.file &&
|
if (given_config_source.file &&
|
||||||
!strcmp(given_config_source.file, "-")) {
|
!strcmp(given_config_source.file, "-")) {
|
||||||
|
@ -1836,11 +1836,14 @@ test_expect_success '--show-scope with --show-origin' '
|
|||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '--local requires a repo' '
|
for opt in --local --worktree
|
||||||
# we expect 128 to ensure that we do not simply
|
do
|
||||||
# fail to find anything and return code "1"
|
test_expect_success "$opt requires a repo" '
|
||||||
test_expect_code 128 nongit git config --local foo.bar
|
# we expect 128 to ensure that we do not simply
|
||||||
'
|
# fail to find anything and return code "1"
|
||||||
|
test_expect_code 128 nongit git config $opt foo.bar
|
||||||
|
'
|
||||||
|
done
|
||||||
|
|
||||||
cat >.git/config <<-\EOF &&
|
cat >.git/config <<-\EOF &&
|
||||||
[core]
|
[core]
|
||||||
|
Reference in New Issue
Block a user