t1300: document current behavior of setting options

This documents current behavior of the config machinery, when changing the value of some settings. This patch just serves to provide a baseline for the follow up that will fix some issues with the current behavior. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Aug 1, 2018 at 12:34 UTC 999d90262727a8e7a25a40dd71073040a2605437
1 file changed +86
t/t1300-config.sh
+86
@@ -1188,6 +1188,92 @@ test_expect_success 'last one wins: three level vars' '
1188 test_cmp expect actual
1189 '
1190
1191 +test_expect_success 'old-fashioned settings are case insensitive' '
1192 + test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
1193 +
1194 + cat >testConfig_actual <<-EOF &&
1195 + [V.A]
1196 + r = value1
1197 + EOF
1198 + q_to_tab >testConfig_expect <<-EOF &&
1199 + [V.A]
1200 + Qr = value2
1201 + EOF
1202 + git config -f testConfig_actual "v.a.r" value2 &&
1203 + test_cmp testConfig_expect testConfig_actual &&
1204 +
1205 + cat >testConfig_actual <<-EOF &&
1206 + [V.A]
1207 + r = value1
1208 + EOF
1209 + q_to_tab >testConfig_expect <<-EOF &&
1210 + [V.A]
1211 + QR = value2
1212 + EOF
1213 + git config -f testConfig_actual "V.a.R" value2 &&
1214 + test_cmp testConfig_expect testConfig_actual &&
1215 +
1216 + cat >testConfig_actual <<-EOF &&
1217 + [V.A]
1218 + r = value1
1219 + EOF
1220 + q_to_tab >testConfig_expect <<-EOF &&
1221 + [V.A]
1222 + r = value1
1223 + Qr = value2
1224 + EOF
1225 + git config -f testConfig_actual "V.A.r" value2 &&
1226 + test_cmp testConfig_expect testConfig_actual &&
1227 +
1228 + cat >testConfig_actual <<-EOF &&
1229 + [V.A]
1230 + r = value1
1231 + EOF
1232 + q_to_tab >testConfig_expect <<-EOF &&
1233 + [V.A]
1234 + r = value1
1235 + Qr = value2
1236 + EOF
1237 + git config -f testConfig_actual "v.A.r" value2 &&
1238 + test_cmp testConfig_expect testConfig_actual
1239 +'
1240 +
1241 +test_expect_success 'setting different case sensitive subsections ' '
1242 + test_when_finished "rm -f testConfig testConfig_expect testConfig_actual" &&
1243 +
1244 + cat >testConfig_actual <<-EOF &&
1245 + [V "A"]
1246 + R = v1
1247 + [K "E"]
1248 + Y = v1
1249 + [a "b"]
1250 + c = v1
1251 + [d "e"]
1252 + f = v1
1253 + EOF
1254 + q_to_tab >testConfig_expect <<-EOF &&
1255 + [V "A"]
1256 + Qr = v2
1257 + [K "E"]
1258 + Qy = v2
1259 + [a "b"]
1260 + Qc = v2
1261 + [d "e"]
1262 + f = v1
1263 + Qf = v2
1264 + EOF
1265 + # exact match
1266 + git config -f testConfig_actual a.b.c v2 &&
1267 + # match section and subsection, key is cased differently.
1268 + git config -f testConfig_actual K.E.y v2 &&
1269 + # section and key are matched case insensitive, but subsection needs
1270 + # to match; When writing out new values only the key is adjusted
1271 + git config -f testConfig_actual v.A.r v2 &&
1272 + # subsection is not matched:
1273 + git config -f testConfig_actual d.E.f v2 &&
1274 + test_cmp testConfig_expect testConfig_actual
1275 +'
1276 +
1277 for VAR in a .a a. a.0b a."b c". a."b c".0d
1278 do
1279 test_expect_success "git -c $VAR=VAL rejects invalid '$VAR'" '