test_cmp expect actual
'
+test_expect_success 'list with nonexistent global config' '
+ rm -rf "$HOME"/.gitconfig "$HOME"/.config/git/config &&
+ git config ${mode_prefix}list --show-scope
+'
+
+test_expect_success 'list --global with nonexistent global config' '
+ rm -rf "$HOME"/.gitconfig "$HOME"/.config/git/config &&
+ test_must_fail git config ${mode_prefix}list --global --show-scope
+'
+
+test_expect_success 'list --global with only home' '
+ rm -rf "$HOME"/.config/git/config &&
+
+ test_when_finished rm -f \"\$HOME\"/.gitconfig &&
+ cat >"$HOME"/.gitconfig <<-EOF &&
+ [home]
+ config = true
+ EOF
+
+ cat >expect <<-EOF &&
+ global home.config=true
+ EOF
+ git config ${mode_prefix}list --global --show-scope >output &&
+ test_cmp expect output
+'
+
+test_expect_success 'list --global with only xdg' '
+ rm -f "$HOME"/.gitconfig &&
+
+ test_when_finished rm -rf \"\$HOME\"/.config/git &&
+ mkdir -p "$HOME"/.config/git &&
+ cat >"$HOME"/.config/git/config <<-EOF &&
+ [xdg]
+ config = true
+ EOF
+
+ cat >expect <<-EOF &&
+ global xdg.config=true
+ EOF
+ git config ${mode_prefix}list --global --show-scope >output &&
+ test_cmp expect output
+'
+
+test_expect_success 'list --global with both home and xdg' '
+ test_when_finished rm -f \"\$HOME\"/.gitconfig &&
+ cat >"$HOME"/.gitconfig <<-EOF &&
+ [home]
+ config = true
+ EOF
+
+ test_when_finished rm -rf \"\$HOME\"/.config/git &&
+ mkdir -p "$HOME"/.config/git &&
+ cat >"$HOME"/.config/git/config <<-EOF &&
+ [xdg]
+ config = true
+ EOF
+
+ cat >expect <<-EOF &&
+ global file:$HOME/.config/git/config xdg.config=true
+ global file:$HOME/.gitconfig home.config=true
+ EOF
+ git config ${mode_prefix}list --global --show-scope --show-origin >output &&
+ ! test_cmp expect output
+'
+
test_expect_success 'override global and system config' '
test_when_finished rm -f \"\$HOME\"/.gitconfig &&
cat >"$HOME"/.gitconfig <<-EOF &&
>.gitconfig &&
echo "[user]" >.gitconfig &&
echo " name = read_gitconfig" >>.gitconfig &&
- echo user.name=read_gitconfig >expected &&
+ echo user.name=read_config >expected &&
+ echo user.name=read_gitconfig >>expected &&
git config --global --list >actual &&
- test_cmp expected actual
+ ! test_cmp expected actual
'