~ubuntu-branches/ubuntu/intrepid/git-core/intrepid-updates

« back to all changes in this revision

Viewing changes to t/t1300-repo-config.sh

  • Committer: Package Import Robot
  • Author(s): Gerrit Pape
  • Date: 2007-04-22 13:31:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20070422133105-xg8fnm18r2cxcbg1
Tags: upstream-1.5.1.2
ImportĀ upstreamĀ versionĀ 1.5.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# Copyright (c) 2005 Johannes Schindelin
4
4
#
5
5
 
6
 
test_description='Test git-repo-config in different settings'
 
6
test_description='Test git-config in different settings'
7
7
 
8
8
. ./test-lib.sh
9
9
 
10
10
test -f .git/config && rm .git/config
11
11
 
12
 
git-repo-config core.penguin "little blue"
 
12
git-config core.penguin "little blue"
13
13
 
14
14
cat > expect << EOF
15
15
[core]
18
18
 
19
19
test_expect_success 'initial' 'cmp .git/config expect'
20
20
 
21
 
git-repo-config Core.Movie BadPhysics
 
21
git-config Core.Movie BadPhysics
22
22
 
23
23
cat > expect << EOF
24
24
[core]
28
28
 
29
29
test_expect_success 'mixed case' 'cmp .git/config expect'
30
30
 
31
 
git-repo-config Cores.WhatEver Second
 
31
git-config Cores.WhatEver Second
32
32
 
33
33
cat > expect << EOF
34
34
[core]
40
40
 
41
41
test_expect_success 'similar section' 'cmp .git/config expect'
42
42
 
43
 
git-repo-config CORE.UPPERCASE true
 
43
git-config CORE.UPPERCASE true
44
44
 
45
45
cat > expect << EOF
46
46
[core]
54
54
test_expect_success 'similar section' 'cmp .git/config expect'
55
55
 
56
56
test_expect_success 'replace with non-match' \
57
 
        'git-repo-config core.penguin kingpin !blue'
 
57
        'git-config core.penguin kingpin !blue'
58
58
 
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'
61
61
 
62
62
cat > expect << EOF
63
63
[core]
86
86
cp .git/config .git/config2
87
87
 
88
88
test_expect_success 'multiple unset' \
89
 
        'git-repo-config --unset-all beta.haha'
 
89
        'git-config --unset-all beta.haha'
90
90
 
91
91
cat > expect << EOF
92
92
[beta] ; silly comment # another comment
102
102
mv .git/config2 .git/config
103
103
 
104
104
test_expect_success '--replace-all' \
105
 
        'git-repo-config --replace-all beta.haha gamma'
 
105
        'git-config --replace-all beta.haha gamma'
106
106
 
107
107
cat > expect << EOF
108
108
[beta] ; silly comment # another comment
116
116
 
117
117
test_expect_success 'all replaced' 'cmp .git/config expect'
118
118
 
119
 
git-repo-config beta.haha alpha
 
119
git-config beta.haha alpha
120
120
 
121
121
cat > expect << EOF
122
122
[beta] ; silly comment # another comment
130
130
 
131
131
test_expect_success 'really mean test' 'cmp .git/config expect'
132
132
 
133
 
git-repo-config nextsection.nonewline wow
 
133
git-config nextsection.nonewline wow
134
134
 
135
135
cat > expect << EOF
136
136
[beta] ; silly comment # another comment
145
145
 
146
146
test_expect_success 'really really mean test' 'cmp .git/config expect'
147
147
 
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
150
150
 
151
151
cat > expect << EOF
152
152
[beta] ; silly comment # another comment
160
160
 
161
161
test_expect_success 'unset' 'cmp .git/config expect'
162
162
 
163
 
git-repo-config nextsection.NoNewLine "wow2 for me" "for me$"
 
163
git-config nextsection.NoNewLine "wow2 for me" "for me$"
164
164
 
165
165
cat > expect << EOF
166
166
[beta] ; silly comment # another comment
176
176
test_expect_success 'multivar' 'cmp .git/config expect'
177
177
 
178
178
test_expect_success 'non-match' \
179
 
        'git-repo-config --get nextsection.nonewline !for'
 
179
        'git-config --get nextsection.nonewline !for'
180
180
 
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)'
183
183
 
184
184
test_expect_failure 'ambiguous get' \
185
 
        'git-repo-config --get nextsection.nonewline'
 
185
        'git-config --get nextsection.nonewline'
186
186
 
187
187
test_expect_success 'get multivar' \
188
 
        'git-repo-config --get-all nextsection.nonewline'
 
188
        'git-config --get-all nextsection.nonewline'
189
189
 
190
 
git-repo-config nextsection.nonewline "wow3" "wow$"
 
190
git-config nextsection.nonewline "wow3" "wow$"
191
191
 
192
192
cat > expect << EOF
193
193
[beta] ; silly comment # another comment
202
202
 
203
203
test_expect_success 'multivar replace' 'cmp .git/config expect'
204
204
 
205
 
test_expect_failure 'ambiguous value' 'git-repo-config nextsection.nonewline'
 
205
test_expect_failure 'ambiguous value' 'git-config nextsection.nonewline'
206
206
 
207
207
test_expect_failure 'ambiguous unset' \
208
 
        'git-repo-config --unset nextsection.nonewline'
 
208
        'git-config --unset nextsection.nonewline'
209
209
 
210
210
test_expect_failure 'invalid unset' \
211
 
        'git-repo-config --unset somesection.nonewline'
 
211
        'git-config --unset somesection.nonewline'
212
212
 
213
 
git-repo-config --unset nextsection.nonewline "wow3$"
 
213
git-config --unset nextsection.nonewline "wow3$"
214
214
 
215
215
cat > expect << EOF
216
216
[beta] ; silly comment # another comment
224
224
 
225
225
test_expect_success 'multivar unset' 'cmp .git/config expect'
226
226
 
227
 
test_expect_failure 'invalid key' 'git-repo-config inval.2key blabla'
 
227
test_expect_failure 'invalid key' 'git-config inval.2key blabla'
228
228
 
229
 
test_expect_success 'correct key' 'git-repo-config 123456.a123 987'
 
229
test_expect_success 'correct key' 'git-config 123456.a123 987'
230
230
 
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'
233
233
 
234
234
cat > expect << EOF
235
235
[beta] ; silly comment # another comment
255
255
EOF
256
256
 
257
257
test_expect_success 'working --list' \
258
 
        'git-repo-config --list > output && cmp output expect'
 
258
        'git-config --list > output && cmp output expect'
259
259
 
260
260
cat > expect << EOF
261
261
beta.noindent sillyValue
263
263
EOF
264
264
 
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'
 
267
 
 
268
git-config --add nextsection.nonewline "wow4 for you"
 
269
 
 
270
cat > expect << EOF
 
271
wow2 for me
 
272
wow4 for you
 
273
EOF
 
274
 
 
275
test_expect_success '--add' \
 
276
        'git-config --get-all nextsection.nonewline > output && cmp output expect'
267
277
 
268
278
cat > .git/config << EOF
269
279
[novalue]
271
281
EOF
272
282
 
273
283
test_expect_success 'get variable with no value' \
274
 
        'git-repo-config --get novalue.variable ^$'
 
284
        'git-config --get novalue.variable ^$'
275
285
 
276
 
git-repo-config > output 2>&1
 
286
git-config > output 2>&1
277
287
 
278
288
test_expect_success 'no arguments, but no crash' \
279
289
        "test $? = 129 && grep usage output"
283
293
        c = d
284
294
EOF
285
295
 
286
 
git-repo-config a.x y
 
296
git-config a.x y
287
297
 
288
298
cat > expect << EOF
289
299
[a.b]
294
304
 
295
305
test_expect_success 'new section is partial match of another' 'cmp .git/config expect'
296
306
 
297
 
git-repo-config b.x y
298
 
git-repo-config a.b c
 
307
git-config b.x y
 
308
git-config a.b c
299
309
 
300
310
cat > expect << EOF
301
311
[a.b]
318
328
ein.bahn=strasse
319
329
EOF
320
330
 
321
 
GIT_CONFIG=other-config git-repo-config -l > output
 
331
GIT_CONFIG=other-config git-config -l > output
322
332
 
323
333
test_expect_success 'alternative GIT_CONFIG' 'cmp output expect'
324
334
 
325
 
GIT_CONFIG=other-config git-repo-config anwohner.park ausweis
 
335
GIT_CONFIG=other-config git-config anwohner.park ausweis
326
336
 
327
337
cat > expect << EOF
328
338
[ein]
333
343
 
334
344
test_expect_success '--set in alternative GIT_CONFIG' 'cmp other-config expect'
335
345
 
 
346
cat > .git/config << EOF
 
347
# Hallo
 
348
        #Bello
 
349
[branch "eins"]
 
350
        x = 1
 
351
[branch.eins]
 
352
        y = 1
 
353
        [branch "1 234 blabl/a"]
 
354
weird
 
355
EOF
 
356
 
 
357
test_expect_success "rename section" \
 
358
        "git-config --rename-section branch.eins branch.zwei"
 
359
 
 
360
cat > expect << EOF
 
361
# Hallo
 
362
        #Bello
 
363
[branch "zwei"]
 
364
        x = 1
 
365
[branch "zwei"]
 
366
        y = 1
 
367
        [branch "1 234 blabl/a"]
 
368
weird
 
369
EOF
 
370
 
 
371
test_expect_success "rename succeeded" "git diff expect .git/config"
 
372
 
 
373
test_expect_failure "rename non-existing section" \
 
374
        'git-config --rename-section branch."world domination" branch.drei'
 
375
 
 
376
test_expect_success "rename succeeded" "git diff expect .git/config"
 
377
 
 
378
test_expect_success "rename another section" \
 
379
        'git-config --rename-section branch."1 234 blabl/a" branch.drei'
 
380
 
 
381
cat > expect << EOF
 
382
# Hallo
 
383
        #Bello
 
384
[branch "zwei"]
 
385
        x = 1
 
386
[branch "zwei"]
 
387
        y = 1
 
388
[branch "drei"]
 
389
weird
 
390
EOF
 
391
 
 
392
test_expect_success "rename succeeded" "git diff expect .git/config"
 
393
 
 
394
cat >> .git/config << EOF
 
395
  [branch "zwei"] a = 1 [branch "vier"]
 
396
EOF
 
397
 
 
398
test_expect_success "remove section" "git config --remove-section branch.zwei"
 
399
 
 
400
cat > expect << EOF
 
401
# Hallo
 
402
        #Bello
 
403
[branch "drei"]
 
404
weird
 
405
EOF
 
406
 
 
407
test_expect_success "section was removed properly" \
 
408
        "git diff -u expect .git/config"
 
409
 
 
410
test_expect_success numbers '
 
411
 
 
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"
 
418
'
 
419
 
 
420
rm .git/config
 
421
 
 
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"
 
426
 
 
427
cat > expect << EOF
 
428
[quote]
 
429
        leading = " test"
 
430
        ending = "test "
 
431
        semicolon = "test;test"
 
432
        hash = "test#test"
 
433
EOF
 
434
 
 
435
test_expect_success 'quoting' 'cmp .git/config expect'
 
436
 
 
437
test_expect_failure 'key with newline' 'git config key.with\\\
 
438
newline 123'
 
439
 
 
440
test_expect_success 'value with newline' 'git config key.sub value.with\\\
 
441
newline'
 
442
 
 
443
cat > .git/config <<\EOF
 
444
[section]
 
445
        ; comment \
 
446
        continued = cont\
 
447
inued
 
448
        noncont   = not continued ; \
 
449
        quotecont = "cont;\
 
450
inued"
 
451
EOF
 
452
 
 
453
cat > expect <<\EOF
 
454
section.continued=continued
 
455
section.noncont=not continued
 
456
section.quotecont=cont;inued
 
457
EOF
 
458
 
 
459
git config --list > result
 
460
 
 
461
test_expect_success 'value continued on next line' 'cmp result expect'
 
462
 
336
463
test_done
337
464