Skip to content

Commit 751d3b9

Browse files
dschogitster
authored andcommitted
t1309: document cases where we would want early config not to die()
Jeff King came up with a couple examples that demonstrate how the new read_early_config() that looks harder for the current .git/ directory could die() in an undesirable way. Let's add those cases to the test script, to document what we would like to happen when early config encounters problems. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 01017dc commit 751d3b9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

t/t1309-early-config.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,28 @@ test_expect_success 'ceiling #2' '
4747
test xdg = "$(cat output)"
4848
'
4949

50+
test_with_config () {
51+
rm -rf throwaway &&
52+
git init throwaway &&
53+
(
54+
cd throwaway &&
55+
echo "$*" >.git/config &&
56+
test-config read_early_config early.config
57+
)
58+
}
59+
60+
test_expect_success 'ignore .git/ with incompatible repository version' '
61+
test_with_config "[core]repositoryformatversion = 999999" 2>err &&
62+
grep "warning:.* Expected git repo version <= [1-9]" err
63+
'
64+
65+
test_expect_failure 'ignore .git/ with invalid repository version' '
66+
test_with_config "[core]repositoryformatversion = invalid"
67+
'
68+
69+
70+
test_expect_failure 'ignore .git/ with invalid config' '
71+
test_with_config "["
72+
'
73+
5074
test_done

0 commit comments

Comments
 (0)