@@ -11,6 +11,98 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11
11
TEST_PASSES_SANITIZE_LEAK=true
12
12
. ./test-lib.sh
13
13
14
+ test_expect_success ' setup whitespace config' '
15
+ sed -e "s/^|//" \
16
+ -e "s/[$]$//" \
17
+ -e "s/X/ /g" >.git/config <<-\EOF
18
+ [section]
19
+ | solid = rock
20
+ | sparse = big XX blue
21
+ | sparseAndTail = big XX blue $
22
+ | sparseAndTailQuoted = "big XX blue "
23
+ | sparseAndBiggerTail = big XX blue X X
24
+ | sparseAndBiggerTailQuoted = "big XX blue X X"
25
+ | sparseAndBiggerTailQuotedPlus = "big XX blue X X"X $
26
+ | headAndTail = Xbig blue $
27
+ | headAndTailQuoted = "Xbig blue "
28
+ | headAndTailQuotedPlus = "Xbig blue " $
29
+ | annotated = big blueX# to be discarded
30
+ | annotatedQuoted = "big blue"X# to be discarded
31
+ EOF
32
+ '
33
+
34
+ test_expect_success ' no internal whitespace' '
35
+ echo "rock" >expect &&
36
+ git config --get section.solid >actual &&
37
+ test_cmp expect actual
38
+ '
39
+
40
+ test_expect_success ' internal whitespace' '
41
+ echo "big QQ blue" | q_to_tab >expect &&
42
+ git config --get section.sparse >actual &&
43
+ test_cmp expect actual
44
+ '
45
+
46
+ test_expect_success ' internal and trailing whitespace' '
47
+ echo "big QQ blue" | q_to_tab >expect &&
48
+ git config --get section.sparseAndTail >actual &&
49
+ test_cmp expect actual
50
+ '
51
+
52
+ test_expect_success ' internal and trailing whitespace, all quoted' '
53
+ echo "big QQ blue " | q_to_tab >expect &&
54
+ git config --get section.sparseAndTailQuoted >actual &&
55
+ test_cmp expect actual
56
+ '
57
+
58
+ test_expect_success ' internal and more trailing whitespace' '
59
+ echo "big QQ blue" | q_to_tab >expect &&
60
+ git config --get section.sparseAndBiggerTail >actual &&
61
+ test_cmp expect actual
62
+ '
63
+
64
+ test_expect_success ' internal and more trailing whitespace, all quoted' '
65
+ echo "big QQ blue Q Q" | q_to_tab >expect &&
66
+ git config --get section.sparseAndBiggerTailQuoted >actual &&
67
+ test_cmp expect actual
68
+ '
69
+
70
+ test_expect_success ' internal and more trailing whitespace, not all quoted' '
71
+ echo "big QQ blue Q Q" | q_to_tab >expect &&
72
+ git config --get section.sparseAndBiggerTailQuotedPlus >actual &&
73
+ test_cmp expect actual
74
+ '
75
+
76
+ test_expect_success ' leading and trailing whitespace' '
77
+ echo "big blue" >expect &&
78
+ git config --get section.headAndTail >actual &&
79
+ test_cmp expect actual
80
+ '
81
+
82
+ test_expect_success ' leading and trailing whitespace, all quoted' '
83
+ echo "Qbig blue " | q_to_tab >expect &&
84
+ git config --get section.headAndTailQuoted >actual &&
85
+ test_cmp expect actual
86
+ '
87
+
88
+ test_expect_success ' leading and trailing whitespace, not all quoted' '
89
+ echo "Qbig blue " | q_to_tab >expect &&
90
+ git config --get section.headAndTailQuotedPlus >actual &&
91
+ test_cmp expect actual
92
+ '
93
+
94
+ test_expect_success ' inline comment' '
95
+ echo "big blue" >expect &&
96
+ git config --get section.annotated >actual &&
97
+ test_cmp expect actual
98
+ '
99
+
100
+ test_expect_success ' inline comment, quoted' '
101
+ echo "big blue" >expect &&
102
+ git config --get section.annotatedQuoted >actual &&
103
+ test_cmp expect actual
104
+ '
105
+
14
106
test_expect_success ' clear default config' '
15
107
rm -f .git/config
16
108
'
@@ -1066,9 +1158,25 @@ test_expect_success '--null --get-regexp' '
1066
1158
test_cmp expect result
1067
1159
'
1068
1160
1069
- test_expect_success ' inner whitespace kept verbatim' '
1070
- git config section.val "foo bar" &&
1071
- test_cmp_config "foo bar" section.val
1161
+ test_expect_success ' inner whitespace kept verbatim, spaces only' '
1162
+ echo "foo bar" >expect &&
1163
+ git config section.val "foo bar" &&
1164
+ git config --get section.val >actual &&
1165
+ test_cmp expect actual
1166
+ '
1167
+
1168
+ test_expect_success ' inner whitespace kept verbatim, horizontal tabs only' '
1169
+ echo "fooQQbar" | q_to_tab >expect &&
1170
+ git config section.val "$(cat expect)" &&
1171
+ git config --get section.val >actual &&
1172
+ test_cmp expect actual
1173
+ '
1174
+
1175
+ test_expect_success ' inner whitespace kept verbatim, horizontal tabs and spaces' '
1176
+ echo "foo Q bar" | q_to_tab >expect &&
1177
+ git config section.val "$(cat expect)" &&
1178
+ git config --get section.val >actual &&
1179
+ test_cmp expect actual
1072
1180
'
1073
1181
1074
1182
test_expect_success SYMLINKS ' symlinked configuration' '
0 commit comments