Skip to content

Commit 588a538

Browse files
peffgitster
authored andcommitted
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>
1 parent d819374 commit 588a538

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

environment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static void setup_git_env(void)
169169
git_dir = getenv(GIT_DIR_ENVIRONMENT);
170170
if (!git_dir) {
171171
if (!startup_info->have_repository)
172-
die("BUG: setup_git_env called without repository");
172+
BUG("setup_git_env called without repository");
173173
git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
174174
}
175175
gitfile = read_gitfile(git_dir);

t/t1300-repo-config.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,4 +1539,10 @@ test_expect_success !MINGW '--show-origin blob ref' '
15391539
test_cmp expect output
15401540
'
15411541

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+
15421548
test_done

0 commit comments

Comments
 (0)