3
3
# Copyright (c) 2005 Johannes Schindelin
6
test_description='Test git-repo-config in different settings'
6
test_description='Test git-config in different settings'
10
10
test -f .git/config && rm .git/config
12
git-repo-config core.penguin "little blue"
12
git-config core.penguin "little blue"
14
14
cat > expect << EOF
54
54
test_expect_success 'similar section' 'cmp .git/config expect'
56
56
test_expect_success 'replace with non-match' \
57
'git-repo-config core.penguin kingpin !blue'
57
'git-config core.penguin kingpin !blue'
59
59
test_expect_success 'replace with non-match (actually matching)' \
60
'git-repo-config core.penguin "very blue" !kingpin'
60
'git-config core.penguin "very blue" !kingpin'
62
62
cat > expect << EOF
86
86
cp .git/config .git/config2
88
88
test_expect_success 'multiple unset' \
89
'git-repo-config --unset-all beta.haha'
89
'git-config --unset-all beta.haha'
91
91
cat > expect << EOF
92
92
[beta] ; silly comment # another comment
102
102
mv .git/config2 .git/config
104
104
test_expect_success '--replace-all' \
105
'git-repo-config --replace-all beta.haha gamma'
105
'git-config --replace-all beta.haha gamma'
107
107
cat > expect << EOF
108
108
[beta] ; silly comment # another comment
146
146
test_expect_success 'really really mean test' 'cmp .git/config expect'
148
test_expect_success 'get value' 'test alpha = $(git-repo-config beta.haha)'
149
git-repo-config --unset beta.haha
148
test_expect_success 'get value' 'test alpha = $(git-config beta.haha)'
149
git-config --unset beta.haha
151
151
cat > expect << EOF
152
152
[beta] ; silly comment # another comment
161
161
test_expect_success 'unset' 'cmp .git/config expect'
163
git-repo-config nextsection.NoNewLine "wow2 for me" "for me$"
163
git-config nextsection.NoNewLine "wow2 for me" "for me$"
165
165
cat > expect << EOF
166
166
[beta] ; silly comment # another comment
176
176
test_expect_success 'multivar' 'cmp .git/config expect'
178
178
test_expect_success 'non-match' \
179
'git-repo-config --get nextsection.nonewline !for'
179
'git-config --get nextsection.nonewline !for'
181
181
test_expect_success 'non-match value' \
182
'test wow = $(git-repo-config --get nextsection.nonewline !for)'
182
'test wow = $(git-config --get nextsection.nonewline !for)'
184
184
test_expect_failure 'ambiguous get' \
185
'git-repo-config --get nextsection.nonewline'
185
'git-config --get nextsection.nonewline'
187
187
test_expect_success 'get multivar' \
188
'git-repo-config --get-all nextsection.nonewline'
188
'git-config --get-all nextsection.nonewline'
190
git-repo-config nextsection.nonewline "wow3" "wow$"
190
git-config nextsection.nonewline "wow3" "wow$"
192
192
cat > expect << EOF
193
193
[beta] ; silly comment # another comment
203
203
test_expect_success 'multivar replace' 'cmp .git/config expect'
205
test_expect_failure 'ambiguous value' 'git-repo-config nextsection.nonewline'
205
test_expect_failure 'ambiguous value' 'git-config nextsection.nonewline'
207
207
test_expect_failure 'ambiguous unset' \
208
'git-repo-config --unset nextsection.nonewline'
208
'git-config --unset nextsection.nonewline'
210
210
test_expect_failure 'invalid unset' \
211
'git-repo-config --unset somesection.nonewline'
211
'git-config --unset somesection.nonewline'
213
git-repo-config --unset nextsection.nonewline "wow3$"
213
git-config --unset nextsection.nonewline "wow3$"
215
215
cat > expect << EOF
216
216
[beta] ; silly comment # another comment
225
225
test_expect_success 'multivar unset' 'cmp .git/config expect'
227
test_expect_failure 'invalid key' 'git-repo-config inval.2key blabla'
227
test_expect_failure 'invalid key' 'git-config inval.2key blabla'
229
test_expect_success 'correct key' 'git-repo-config 123456.a123 987'
229
test_expect_success 'correct key' 'git-config 123456.a123 987'
231
231
test_expect_success 'hierarchical section' \
232
'git-repo-config Version.1.2.3eX.Alpha beta'
232
'git-config Version.1.2.3eX.Alpha beta'
234
234
cat > expect << EOF
235
235
[beta] ; silly comment # another comment
265
265
test_expect_success '--get-regexp' \
266
'git-repo-config --get-regexp in > output && cmp output expect'
266
'git-config --get-regexp in > output && cmp output expect'
268
git-config --add nextsection.nonewline "wow4 for you"
275
test_expect_success '--add' \
276
'git-config --get-all nextsection.nonewline > output && cmp output expect'
268
278
cat > .git/config << EOF
273
283
test_expect_success 'get variable with no value' \
274
'git-repo-config --get novalue.variable ^$'
284
'git-config --get novalue.variable ^$'
276
git-repo-config > output 2>&1
286
git-config > output 2>&1
278
288
test_expect_success 'no arguments, but no crash' \
279
289
"test $? = 129 && grep usage output"
321
GIT_CONFIG=other-config git-repo-config -l > output
331
GIT_CONFIG=other-config git-config -l > output
323
333
test_expect_success 'alternative GIT_CONFIG' 'cmp output expect'
325
GIT_CONFIG=other-config git-repo-config anwohner.park ausweis
335
GIT_CONFIG=other-config git-config anwohner.park ausweis
327
337
cat > expect << EOF
334
344
test_expect_success '--set in alternative GIT_CONFIG' 'cmp other-config expect'
346
cat > .git/config << EOF
353
[branch "1 234 blabl/a"]
357
test_expect_success "rename section" \
358
"git-config --rename-section branch.eins branch.zwei"
367
[branch "1 234 blabl/a"]
371
test_expect_success "rename succeeded" "git diff expect .git/config"
373
test_expect_failure "rename non-existing section" \
374
'git-config --rename-section branch."world domination" branch.drei'
376
test_expect_success "rename succeeded" "git diff expect .git/config"
378
test_expect_success "rename another section" \
379
'git-config --rename-section branch."1 234 blabl/a" branch.drei'
392
test_expect_success "rename succeeded" "git diff expect .git/config"
394
cat >> .git/config << EOF
395
[branch "zwei"] a = 1 [branch "vier"]
398
test_expect_success "remove section" "git config --remove-section branch.zwei"
407
test_expect_success "section was removed properly" \
408
"git diff -u expect .git/config"
410
test_expect_success numbers '
412
git-config kilo.gram 1k &&
413
git-config mega.ton 1m &&
414
k=$(git-config --int --get kilo.gram) &&
415
test z1024 = "z$k" &&
416
m=$(git-config --int --get mega.ton) &&
417
test z1048576 = "z$m"
422
git-config quote.leading " test"
423
git-config quote.ending "test "
424
git-config quote.semicolon "test;test"
425
git-config quote.hash "test#test"
431
semicolon = "test;test"
435
test_expect_success 'quoting' 'cmp .git/config expect'
437
test_expect_failure 'key with newline' 'git config key.with\\\
440
test_expect_success 'value with newline' 'git config key.sub value.with\\\
443
cat > .git/config <<\EOF
448
noncont = not continued ; \
454
section.continued=continued
455
section.noncont=not continued
456
section.quotecont=cont;inued
459
git config --list > result
461
test_expect_success 'value continued on next line' 'cmp result expect'