setup_git_env: convert die("BUG") to BUG()
authorJeff King <peff@peff.net>
Sat, 13 May 2017 03:29:18 +0000 (23:29 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 May 2017 02:30:00 +0000 (11:30 +0900)
Converting to BUG() makes it easier to detect and debug
cases where we hit this assertion. Coupled with a new test
in t1300, this shows that the test suite can detect such
corner cases.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
environment.c
t/t1300-repo-config.sh
index ff6e4f06e93d642aa53ba1812c3788b0ccad092e..1f0bda5afabe901bea250e7dabcc39c5325baf88 100644 (file)
@@ -169,7 +169,7 @@ static void setup_git_env(void)
        git_dir = getenv(GIT_DIR_ENVIRONMENT);
        if (!git_dir) {
                if (!startup_info->have_repository)
-                       die("BUG: setup_git_env called without repository");
+                       BUG("setup_git_env called without repository");
                git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
        }
        gitfile = read_gitfile(git_dir);
index afcca0d52c377cfabd6463f060d1b183937ba9de..867704a64280eb1905fcc2e88ac9b4a337584785 100755 (executable)
@@ -1539,4 +1539,10 @@ test_expect_success !MINGW '--show-origin blob ref' '
        test_cmp expect output
 '
 
+test_expect_failure '--local requires a repo' '
+       # 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 --local foo.bar
+'
+
 test_done