setup_git_env: convert die("BUG") to BUG()

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>

Jeff King committed May 12, 2017 at 23:29 UTC 588a538ae554f61a37d43c972da75d0f7c3ed484
2 files changed +7 -1
environment.c
+1 -1
@@ -169,7 +169,7 @@ static void setup_git_env(void)
169 git_dir = getenv(GIT_DIR_ENVIRONMENT);
170 if (!git_dir) {
171 if (!startup_info->have_repository)
172 - die("BUG: setup_git_env called without repository");
172 + BUG("setup_git_env called without repository");
173 git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
174 }
175 gitfile = read_gitfile(git_dir);
t/t1300-repo-config.sh
+6
@@ -1539,4 +1539,10 @@ test_expect_success !MINGW '--show-origin blob ref' '
1539 test_cmp expect output
1540 '
1541
1542 +test_expect_failure '--local requires a repo' '
1543 + # we expect 128 to ensure that we do not simply
1544 + # fail to find anything and return code "1"
1545 + test_expect_code 128 nongit git config --local foo.bar
1546 +'
1547 +
1548 test_done