summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-02-24 12:48:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-25 18:52:32 (GMT)
commit638fa623d5b5fb392a062edf61ccf086d35ab26b (patch)
tree84302c056b5ea59b7e0dd1079b8dc1d14b869ab5 /t
parent326e5bc91eecf73234ead29636207bc516573e79 (diff)
downloadgit-638fa623d5b5fb392a062edf61ccf086d35ab26b.zip
git-638fa623d5b5fb392a062edf61ccf086d35ab26b.tar.gz
git-638fa623d5b5fb392a062edf61ccf086d35ab26b.tar.bz2
git config: report when trying to modify a non-existing repo config
It is a pilot error to call `git config section.key value` outside of any Git worktree. The message error: could not lock config file .git/config: No such file or directory is not very helpful in that situation, though. Let's print a helpful message instead. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1308-config-set.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh
index 91235b7..9863d0d 100755
--- a/t/t1308-config-set.sh
+++ b/t/t1308-config-set.sh
@@ -218,4 +218,15 @@ test_expect_success 'check line errors for malformed values' '
test_i18ngrep "fatal: .*alias\.br.*\.git/config.*line 2" result
'
+test_expect_success 'error on modifying repo config without repo' '
+ mkdir no-repo &&
+ (
+ GIT_CEILING_DIRECTORIES=$(pwd) &&
+ export GIT_CEILING_DIRECTORIES &&
+ cd no-repo &&
+ test_must_fail git config a.b c 2>err &&
+ grep "not in a git directory" err
+ )
+'
+
test_done