@@ -22,6 +22,8 @@ legacy)
22
22
mode_get_regexp=" --get-regexp"
23
23
mode_set=" "
24
24
mode_replace_all=" --replace-all"
25
+ mode_unset=" --unset"
26
+ mode_unset_all=" --unset-all"
25
27
;;
26
28
subcommands)
27
29
mode_prefix=" "
@@ -30,6 +32,8 @@ subcommands)
30
32
mode_get_regexp=" get --regexp --all --show-names"
31
33
mode_set=" set"
32
34
mode_replace_all=" set --all"
35
+ mode_unset=" unset"
36
+ mode_unset_all=" unset --all"
33
37
;;
34
38
* )
35
39
BUG " unknown mode $mode " ;;
@@ -259,7 +263,7 @@ foo = bar
259
263
EOF
260
264
261
265
test_expect_success ' unset with cont. lines' '
262
- git config --unset beta.baz
266
+ git config ${mode_unset} beta.baz
263
267
'
264
268
265
269
cat > expect << \EOF
286
290
cp .git/config .git/config2
287
291
288
292
test_expect_success ' multiple unset' '
289
- git config --unset-all beta.haha
293
+ git config ${mode_unset_all} beta.haha
290
294
'
291
295
292
296
cat > expect << EOF
@@ -372,7 +376,7 @@ noIndent= sillyValue ; 'nother silly comment
372
376
nonewline = wow
373
377
EOF
374
378
test_expect_success ' unset' '
375
- git config --unset beta.haha &&
379
+ git config ${mode_unset} beta.haha &&
376
380
test_cmp expect .git/config
377
381
'
378
382
@@ -428,11 +432,11 @@ test_expect_success 'multivar replace' '
428
432
'
429
433
430
434
test_expect_success ' ambiguous unset' '
431
- test_must_fail git config --unset nextsection.nonewline
435
+ test_must_fail git config ${mode_unset} nextsection.nonewline
432
436
'
433
437
434
438
test_expect_success ' invalid unset' '
435
- test_must_fail git config --unset somesection.nonewline
439
+ test_must_fail git config ${mode_unset} somesection.nonewline
436
440
'
437
441
438
442
cat > expect << EOF
@@ -446,7 +450,12 @@ noIndent= sillyValue ; 'nother silly comment
446
450
EOF
447
451
448
452
test_expect_success ' multivar unset' '
449
- git config --unset nextsection.nonewline "wow3$" &&
453
+ case "$mode" in
454
+ legacy)
455
+ git config --unset nextsection.nonewline "wow3$";;
456
+ subcommands)
457
+ git config unset --value="wow3$" nextsection.nonewline;;
458
+ esac &&
450
459
test_cmp expect .git/config
451
460
'
452
461
@@ -2013,7 +2022,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
2013
2022
# please be careful when you update the above variable
2014
2023
EOF
2015
2024
2016
- git config --unset section.key &&
2025
+ git config ${mode_unset} section.key &&
2017
2026
test_cmp expect .git/config &&
2018
2027
2019
2028
cat >.git/config <<-\EOF &&
@@ -2026,7 +2035,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
2026
2035
[next-section]
2027
2036
EOF
2028
2037
2029
- git config --unset section.key &&
2038
+ git config ${mode_unset} section.key &&
2030
2039
test_cmp expect .git/config &&
2031
2040
2032
2041
q_to_tab >.git/config <<-\EOF &&
@@ -2036,7 +2045,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
2036
2045
[two]
2037
2046
key = true
2038
2047
EOF
2039
- git config --unset two.key &&
2048
+ git config ${mode_unset} two.key &&
2040
2049
! grep two .git/config &&
2041
2050
2042
2051
q_to_tab >.git/config <<-\EOF &&
@@ -2046,7 +2055,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
2046
2055
[one]
2047
2056
key = true
2048
2057
EOF
2049
- git config --unset-all one.key &&
2058
+ git config ${mode_unset_all} one.key &&
2050
2059
test_line_count = 0 .git/config &&
2051
2060
2052
2061
q_to_tab >.git/config <<-\EOF &&
@@ -2056,7 +2065,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
2056
2065
[two]
2057
2066
Qkey = true
2058
2067
EOF
2059
- git config --unset two.key &&
2068
+ git config ${mode_unset} two.key &&
2060
2069
grep two .git/config &&
2061
2070
2062
2071
q_to_tab >.git/config <<-\EOF &&
@@ -2068,7 +2077,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
2068
2077
[TWO "subsection"]
2069
2078
[one]
2070
2079
EOF
2071
- git config --unset two.subsection.key &&
2080
+ git config ${mode_unset} two.subsection.key &&
2072
2081
test "not [two subsection]" = "$(git config ${mode_get} one.key)" &&
2073
2082
test_line_count = 3 .git/config
2074
2083
'
@@ -2080,7 +2089,7 @@ test_expect_success '--unset-all removes section if empty & uncommented' '
2080
2089
key = value2
2081
2090
EOF
2082
2091
2083
- git config --unset-all section.key &&
2092
+ git config ${mode_unset_all} section.key &&
2084
2093
test_line_count = 0 .git/config
2085
2094
'
2086
2095
@@ -2604,8 +2613,8 @@ test_expect_success 'refuse --fixed-value for incompatible actions' '
2604
2613
test_must_fail git config ${mode_prefix}get --file=config --fixed-value dev.null &&
2605
2614
test_must_fail git config ${mode_get_all} --file=config --fixed-value dev.null &&
2606
2615
test_must_fail git config ${mode_get_regexp} --file=config --fixed-value "dev.*" &&
2607
- test_must_fail git config --file=config --fixed-value --unset dev.null &&
2608
- test_must_fail git config --file=config --fixed-value --unset-all dev.null
2616
+ test_must_fail git config ${mode_unset} --file=config --fixed-value dev.null &&
2617
+ test_must_fail git config ${mode_unset_all} --file=config --fixed-value dev.null
2609
2618
'
2610
2619
2611
2620
test_expect_success ' --fixed-value uses exact string matching' '
@@ -2635,6 +2644,11 @@ test_expect_success '--fixed-value uses exact string matching' '
2635
2644
git config --file=config --fixed-value --unset fixed.test "$META" &&
2636
2645
test_must_fail git config ${mode_get} --file=config fixed.test &&
2637
2646
2647
+ cp initial config &&
2648
+ test_must_fail git config unset --file=config --value="$META" fixed.test &&
2649
+ git config unset --file=config --fixed-value --value="$META" fixed.test &&
2650
+ test_must_fail git config ${mode_get} --file=config fixed.test &&
2651
+
2638
2652
cp initial config &&
2639
2653
test_must_fail git config --file=config --unset-all fixed.test "$META" &&
2640
2654
git config --file=config --fixed-value --unset-all fixed.test "$META" &&
0 commit comments