test_expect_success 'multiple unset is correct' 'cmp .git/config expect'
-mv .git/config2 .git/config
+cp .git/config2 .git/config
+
+test_expect_success '--replace-all missing value' '
+ test_must_fail git config --replace-all beta.haha &&
+ test_cmp .git/config2 .git/config
+'
+
+rm .git/config2
test_expect_success '--replace-all' \
'git config --replace-all beta.haha gamma'
'test wow = $(git config --get nextsection.nonewline !for)'
test_expect_success 'ambiguous get' '
- ! git config --get nextsection.nonewline
+ test_must_fail git config --get nextsection.nonewline
'
test_expect_success 'get multivar' \
test_expect_success 'multivar replace' 'cmp .git/config expect'
test_expect_success 'ambiguous value' '
- ! git config nextsection.nonewline
+ test_must_fail git config nextsection.nonewline
'
test_expect_success 'ambiguous unset' '
- ! git config --unset nextsection.nonewline
+ test_must_fail git config --unset nextsection.nonewline
'
test_expect_success 'invalid unset' '
- ! git config --unset somesection.nonewline
+ test_must_fail git config --unset somesection.nonewline
'
git config --unset nextsection.nonewline "wow3$"
test_expect_success 'multivar unset' 'cmp .git/config expect'
-test_expect_success 'invalid key' '! git config inval.2key blabla'
+test_expect_success 'invalid key' 'test_must_fail git config inval.2key blabla'
test_expect_success 'correct key' 'git config 123456.a123 987'
'git config --bool emptyvalue.variable > output &&
cmp output expect'
-git config > output 2>&1
-
-test_expect_success 'no arguments, but no crash' \
- "test $? = 129 && grep usage output"
+test_expect_success 'no arguments, but no crash' '
+ test_must_fail git config >output 2>&1 &&
+ grep usage output
+'
cat > .git/config << EOF
[a.b]
test_expect_success 'new variable inserts into proper section' 'cmp .git/config expect'
test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' \
- 'git config --file non-existing-config -l; test $? != 0'
+ 'test_must_fail git config --file non-existing-config -l'
cat > other-config << EOF
[ein]
test_expect_success 'alternative GIT_CONFIG (--file)' \
'git config --file other-config -l > output && cmp output expect'
+test_expect_success 'refer config from subdirectory' '
+ mkdir x &&
+ (
+ cd x &&
+ echo strasse >expect
+ git config --get --file ../other-config ein.bahn >actual &&
+ test_cmp expect actual
+ )
+
+'
+
GIT_CONFIG=other-config git config anwohner.park ausweis
cat > expect << EOF
weird
EOF
-test_expect_success "rename succeeded" "git diff expect .git/config"
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
test_expect_success "rename non-existing section" '
- ! git config --rename-section branch."world domination" branch.drei
+ test_must_fail git config --rename-section \
+ branch."world domination" branch.drei
'
-test_expect_success "rename succeeded" "git diff expect .git/config"
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
test_expect_success "rename another section" \
'git config --rename-section branch."1 234 blabl/a" branch.drei'
weird
EOF
-test_expect_success "rename succeeded" "git diff expect .git/config"
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
+
+cat >> .git/config << EOF
+[branch "vier"] z = 1
+EOF
+
+test_expect_success "rename a section with a var on the same line" \
+ 'git config --rename-section branch.vier branch.zwei'
+
+cat > expect << EOF
+# Hallo
+ #Bello
+[branch "zwei"]
+ x = 1
+[branch "zwei"]
+ y = 1
+[branch "drei"]
+weird
+[branch "zwei"]
+ z = 1
+EOF
+
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
cat >> .git/config << EOF
[branch "zwei"] a = 1 [branch "vier"]
EOF
test_expect_success "section was removed properly" \
- "git diff -u expect .git/config"
+ "test_cmp expect .git/config"
rm .git/config
test_expect_success 'invalid bool (--get)' '
git config bool.nobool foobar &&
- ! git config --bool --get bool.nobool'
+ test_must_fail git config --bool --get bool.nobool'
test_expect_success 'invalid bool (set)' '
- ! git config --bool bool.nobool foobar'
+ test_must_fail git config --bool bool.nobool foobar'
rm .git/config
rm .git/config
+cat >expect <<\EOF
+[path]
+ home = ~/
+ normal = /dev/null
+ trailingtilde = foo~
+EOF
+
+test_expect_success 'set --path' '
+ git config --path path.home "~/" &&
+ git config --path path.normal "/dev/null" &&
+ git config --path path.trailingtilde "foo~" &&
+ test_cmp expect .git/config'
+
+cat >expect <<EOF
+$HOME/
+/dev/null
+foo~
+EOF
+
+test_expect_success 'get --path' '
+ git config --get --path path.home > result &&
+ git config --get --path path.normal >> result &&
+ git config --get --path path.trailingtilde >> result &&
+ test_cmp expect result
+'
+
+rm .git/config
+
git config quote.leading " test"
git config quote.ending "test "
git config quote.semicolon "test;test"
test_expect_success 'quoting' 'cmp .git/config expect'
test_expect_success 'key with newline' '
- ! git config "key.with
+ test_must_fail git config "key.with
newline" 123'
test_expect_success 'value with newline' 'git config key.sub value.with\\\
test_expect_success '--null --get-regexp' 'cmp result expect'
-test_expect_success 'symlinked configuration' '
+test_expect_success 'inner whitespace kept verbatim' '
+ git config section.val "foo bar" &&
+ test "z$(git config section.val)" = "zfoo bar"
+'
+
+test_expect_success SYMLINKS 'symlinked configuration' '
ln -s notyet myconfig &&
GIT_CONFIG=myconfig git config test.frotz nitfol &&
'
+test_expect_success 'check split_cmdline return' "
+ git config alias.split-cmdline-fix 'echo \"' &&
+ test_must_fail git split-cmdline-fix &&
+ echo foo > foo &&
+ git add foo &&
+ git commit -m 'initial commit' &&
+ git config branch.master.mergeoptions 'echo \"' &&
+ test_must_fail git merge master
+ "
+
test_done