Merge branch 'jk/config-blob-sans-repo'
authorJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 12:51:27 +0000 (21:51 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 12:51:27 +0000 (21:51 +0900)
Error codepath fix.

* jk/config-blob-sans-repo:
config: die when --blob is used outside a repository

builtin/config.c
t/t1307-config-blob.sh
index 1e31aa9f8d98ffa6790ba2c6023634841b1abf74..b29d26dede79b9a5c46bdc4f951b22e7b88310b3 100644 (file)
@@ -602,6 +602,9 @@ int cmd_config(int argc, const char **argv, const char *prefix)
        if (use_local_config && nongit)
                die(_("--local 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 &&
                        !strcmp(given_config_source.file, "-")) {
                given_config_source.file = NULL;
index eed31ffa30eebaa994b2fee569eb753e2a6a1477..37dc689d8c98fd776895e1ce6d18faee092001d3 100755 (executable)
@@ -73,4 +73,8 @@ test_expect_success 'can parse blob ending with CR' '
        test_cmp expect actual
 '
 
+test_expect_success 'config --blob outside of a repository is an error' '
+       test_must_fail nongit git config --blob=foo --list
+'
+
 test_done