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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Mar 13, 2017 at 21:11 UTC
751d3b9415fc08c8cc926f55646b735b0237fd4a
1 file changed
+24
t/t1309-early-config.sh
+24
@@ -47,4 +47,28 @@ test_expect_success 'ceiling #2' '
47
test xdg = "$(cat output)"
48
'
49
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
+
74
test_done