@@ -22,6 +22,8 @@ legacy)
2222 mode_get_regexp=" --get-regexp"
2323 mode_set=" "
2424 mode_replace_all=" --replace-all"
25+ mode_unset=" --unset"
26+ mode_unset_all=" --unset-all"
2527 ;;
2628subcommands)
2729 mode_prefix=" "
@@ -30,6 +32,8 @@ subcommands)
3032 mode_get_regexp=" get --regexp --all --show-names"
3133 mode_set=" set"
3234 mode_replace_all=" set --all"
35+ mode_unset=" unset"
36+ mode_unset_all=" unset --all"
3337 ;;
3438* )
3539 BUG " unknown mode $mode " ;;
@@ -259,7 +263,7 @@ foo = bar
259263EOF
260264
261265test_expect_success ' unset with cont. lines' '
262- git config --unset beta.baz
266+ git config ${mode_unset} beta.baz
263267'
264268
265269cat > expect << \EOF
286290cp .git/config .git/config2
287291
288292test_expect_success ' multiple unset' '
289- git config --unset-all beta.haha
293+ git config ${mode_unset_all} beta.haha
290294'
291295
292296cat > expect << EOF
@@ -372,7 +376,7 @@ noIndent= sillyValue ; 'nother silly comment
372376 nonewline = wow
373377EOF
374378test_expect_success ' unset' '
375- git config --unset beta.haha &&
379+ git config ${mode_unset} beta.haha &&
376380 test_cmp expect .git/config
377381'
378382
@@ -428,11 +432,11 @@ test_expect_success 'multivar replace' '
428432'
429433
430434test_expect_success ' ambiguous unset' '
431- test_must_fail git config --unset nextsection.nonewline
435+ test_must_fail git config ${mode_unset} nextsection.nonewline
432436'
433437
434438test_expect_success ' invalid unset' '
435- test_must_fail git config --unset somesection.nonewline
439+ test_must_fail git config ${mode_unset} somesection.nonewline
436440'
437441
438442cat > expect << EOF
@@ -446,7 +450,12 @@ noIndent= sillyValue ; 'nother silly comment
446450EOF
447451
448452test_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 &&
450459 test_cmp expect .git/config
451460'
452461
@@ -2013,7 +2022,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
20132022 # please be careful when you update the above variable
20142023 EOF
20152024
2016- git config --unset section.key &&
2025+ git config ${mode_unset} section.key &&
20172026 test_cmp expect .git/config &&
20182027
20192028 cat >.git/config <<-\EOF &&
@@ -2026,7 +2035,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
20262035 [next-section]
20272036 EOF
20282037
2029- git config --unset section.key &&
2038+ git config ${mode_unset} section.key &&
20302039 test_cmp expect .git/config &&
20312040
20322041 q_to_tab >.git/config <<-\EOF &&
@@ -2036,7 +2045,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
20362045 [two]
20372046 key = true
20382047 EOF
2039- git config --unset two.key &&
2048+ git config ${mode_unset} two.key &&
20402049 ! grep two .git/config &&
20412050
20422051 q_to_tab >.git/config <<-\EOF &&
@@ -2046,7 +2055,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
20462055 [one]
20472056 key = true
20482057 EOF
2049- git config --unset-all one.key &&
2058+ git config ${mode_unset_all} one.key &&
20502059 test_line_count = 0 .git/config &&
20512060
20522061 q_to_tab >.git/config <<-\EOF &&
@@ -2056,7 +2065,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
20562065 [two]
20572066 Qkey = true
20582067 EOF
2059- git config --unset two.key &&
2068+ git config ${mode_unset} two.key &&
20602069 grep two .git/config &&
20612070
20622071 q_to_tab >.git/config <<-\EOF &&
@@ -2068,7 +2077,7 @@ test_expect_success '--unset last key removes section (except if commented)' '
20682077 [TWO "subsection"]
20692078 [one]
20702079 EOF
2071- git config --unset two.subsection.key &&
2080+ git config ${mode_unset} two.subsection.key &&
20722081 test "not [two subsection]" = "$(git config ${mode_get} one.key)" &&
20732082 test_line_count = 3 .git/config
20742083'
@@ -2080,7 +2089,7 @@ test_expect_success '--unset-all removes section if empty & uncommented' '
20802089 key = value2
20812090 EOF
20822091
2083- git config --unset-all section.key &&
2092+ git config ${mode_unset_all} section.key &&
20842093 test_line_count = 0 .git/config
20852094'
20862095
@@ -2604,8 +2613,8 @@ test_expect_success 'refuse --fixed-value for incompatible actions' '
26042613 test_must_fail git config ${mode_prefix}get --file=config --fixed-value dev.null &&
26052614 test_must_fail git config ${mode_get_all} --file=config --fixed-value dev.null &&
26062615 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
26092618'
26102619
26112620test_expect_success ' --fixed-value uses exact string matching' '
@@ -2635,6 +2644,11 @@ test_expect_success '--fixed-value uses exact string matching' '
26352644 git config --file=config --fixed-value --unset fixed.test "$META" &&
26362645 test_must_fail git config ${mode_get} --file=config fixed.test &&
26372646
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+
26382652 cp initial config &&
26392653 test_must_fail git config --file=config --unset-all fixed.test "$META" &&
26402654 git config --file=config --fixed-value --unset-all fixed.test "$META" &&
0 commit comments