Merge branch 'yd/use-test-config-unconfig'
authorJunio C Hamano <gitster@pobox.com>
Thu, 28 Mar 2013 21:38:27 +0000 (14:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Mar 2013 21:38:27 +0000 (14:38 -0700)
Bulk-update of the test suite.

* yd/use-test-config-unconfig:
t5520: use test_config to set/unset git config variables (leftover bits)
t7600: use test_config to set/unset git config variables
t7502: remove clear_config
t7502: use test_config to set/unset git config variables
t9500: use test_config to set/unset git config variables
t7508: use test_config to set/unset git config variables
t7500: use test_config to set/unset git config variables
t5541: use test_config to set/unset git config variables
t5520: use test_config to set/unset git config variables
t4202: use test_config/test_unconfig to set/unset git config variables
t4034: use test_config/test_unconfig to set/unset git config variables
t4304: use test_config to set/unset git config variables
t3400: use test_config to set/unset git config variables

1  2 
t/t7502-commit.sh
t/t7508-status.sh
diff --combined t/t7502-commit.sh
index f9b44b72449d258647c5278c52e5c792ee10445e,b0ae7059367fdb50dfc04fe87ae69e03abbb03bd..256137f07affdf9ed838bfe5a788c3df11821898
@@@ -171,26 -171,17 +171,25 @@@ test_expect_success 'verbose' 
  
  test_expect_success 'verbose respects diff config' '
  
-       git config color.diff always &&
+       test_config color.diff always &&
        git status -v >actual &&
-       grep "\[1mdiff --git" actual &&
-       git config --unset color.diff
+       grep "\[1mdiff --git" actual
  '
  
 +mesg_with_comment_and_newlines='
 +# text
 +
 +'
 +
 +test_expect_success 'prepare file with comment line and trailing newlines'  '
 +      printf "%s" "$mesg_with_comment_and_newlines" >expect
 +'
 +
  test_expect_success 'cleanup commit messages (verbatim option,-t)' '
  
        echo >>negative &&
 -      { echo;echo "# text";echo; } >expect &&
 -      git commit --cleanup=verbatim -t expect -a &&
 -      git cat-file -p HEAD |sed -e "1,/^\$/d" |head -n 3 >actual &&
 +      git commit --cleanup=verbatim --no-status -t expect -a &&
 +      git cat-file -p HEAD |sed -e "1,/^\$/d" >actual &&
        test_cmp expect actual
  
  '
@@@ -207,7 -198,7 +206,7 @@@ test_expect_success 'cleanup commit mes
  test_expect_success 'cleanup commit messages (verbatim option,-m)' '
  
        echo >>negative &&
 -      git commit --cleanup=verbatim -m "$(cat expect)" -a &&
 +      git commit --cleanup=verbatim -m "$mesg_with_comment_and_newlines" -a &&
        git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
        test_cmp expect actual
  
@@@ -263,40 -254,32 +262,40 @@@ test_expect_success 'cleanup commit mes
  test_expect_success 'cleanup commit message (no config and no option uses default)' '
        echo content >>file &&
        git add file &&
 -      test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
 -      git commit --no-status &&
 +      (
 +        test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
 +        git commit --no-status
 +      ) &&
        commit_msg_is "commit message"
  '
  
  test_expect_success 'cleanup commit message (option overrides default)' '
        echo content >>file &&
        git add file &&
 -      test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
 -      git commit --cleanup=whitespace --no-status &&
 +      (
 +        test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
 +        git commit --cleanup=whitespace --no-status
 +      ) &&
        commit_msg_is "commit message # comment"
  '
  
  test_expect_success 'cleanup commit message (config overrides default)' '
        echo content >>file &&
        git add file &&
 -      test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
 -      git -c commit.cleanup=whitespace commit --no-status &&
 +      (
 +        test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
 +        git -c commit.cleanup=whitespace commit --no-status
 +      ) &&
        commit_msg_is "commit message # comment"
  '
  
  test_expect_success 'cleanup commit message (option overrides config)' '
        echo content >>file &&
        git add file &&
 -      test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
 -      git -c commit.cleanup=whitespace commit --cleanup=default &&
 +      (
 +        test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
 +        git -c commit.cleanup=whitespace commit --cleanup=default
 +      ) &&
        commit_msg_is "commit message"
  '
  
@@@ -435,16 -418,6 +434,6 @@@ EO
  
  echo '## Custom template' >template
  
- clear_config () {
-       (
-               git config --unset-all "$1"
-               case $? in
-               0|5)    exit 0 ;;
-               *)      exit 1 ;;
-               esac
-       )
- }
  try_commit () {
        git reset --hard &&
        echo >>negative &&
  try_commit_status_combo () {
  
        test_expect_success 'commit' '
-               clear_config commit.status &&
                try_commit "" &&
                test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
  
        test_expect_success 'commit' '
-               clear_config commit.status &&
                try_commit "" &&
                test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
  
        test_expect_success 'commit --status' '
-               clear_config commit.status &&
                try_commit --status &&
                test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
  
        test_expect_success 'commit --no-status' '
-               clear_config commit.status &&
                try_commit --no-status &&
                test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
  
        test_expect_success 'commit with commit.status = yes' '
-               clear_config commit.status &&
-               git config commit.status yes &&
+               test_config commit.status yes &&
                try_commit "" &&
                test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
  
        test_expect_success 'commit with commit.status = no' '
-               clear_config commit.status &&
-               git config commit.status no &&
+               test_config commit.status no &&
                try_commit "" &&
                test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
  
        test_expect_success 'commit --status with commit.status = yes' '
-               clear_config commit.status &&
-               git config commit.status yes &&
+               test_config commit.status yes &&
                try_commit --status &&
                test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
  
        test_expect_success 'commit --no-status with commit.status = yes' '
-               clear_config commit.status &&
-               git config commit.status yes &&
+               test_config commit.status yes &&
                try_commit --no-status &&
                test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
  
        test_expect_success 'commit --status with commit.status = no' '
-               clear_config commit.status &&
-               git config commit.status no &&
+               test_config commit.status no &&
                try_commit --status &&
                test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
  
        test_expect_success 'commit --no-status with commit.status = no' '
-               clear_config commit.status &&
-               git config commit.status no &&
+               test_config commit.status no &&
                try_commit --no-status &&
                test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
        '
@@@ -534,8 -497,7 +513,7 @@@ use_template="-t template
  try_commit_status_combo
  
  test_expect_success 'commit --status with custom comment character' '
-       test_when_finished "git config --unset core.commentchar" &&
-       git config core.commentchar ";" &&
+       test_config core.commentchar ";" &&
        try_commit --status &&
        test_i18ngrep "^; Changes to be committed:" .git/COMMIT_EDITMSG
  '
diff --combined t/t7508-status.sh
index aecb4d1e5fdc1e966aad07ee1f1e7af834388bb2,55ecd260863d239750bc55f288befe7ec25d242b..e2ffdacc267c22e369247791e24338a20badf94d
@@@ -8,7 -8,6 +8,7 @@@ test_description='git status
  . ./test-lib.sh
  
  test_expect_success 'status -h in broken repository' '
 +      git config --global advice.statusuoption false &&
        mkdir broken &&
        test_when_finished "rm -fr broken" &&
        (
@@@ -131,8 -130,7 +131,7 @@@ cat >expect <<\EO
  EOF
  
  test_expect_success 'status (advice.statusHints false)' '
-       test_when_finished "git config --unset advice.statusHints" &&
-       git config advice.statusHints false &&
+       test_config advice.statusHints false &&
        git status >output &&
        test_i18ncmp expect output
  
@@@ -332,8 -330,7 +331,7 @@@ test_expect_success 'status -uno' 
  '
  
  test_expect_success 'status (status.showUntrackedFiles no)' '
-       git config status.showuntrackedfiles no
-       test_when_finished "git config --unset status.showuntrackedfiles" &&
+       test_config status.showuntrackedfiles no &&
        git status >output &&
        test_i18ncmp expect output
  '
@@@ -348,12 -345,11 +346,11 @@@ cat >expect <<EO
  #
  # Untracked files not listed
  EOF
- git config advice.statusHints false
  test_expect_success 'status -uno (advice.statusHints false)' '
+       test_config advice.statusHints false &&
        git status -uno >output &&
        test_i18ncmp expect output
  '
- git config --unset advice.statusHints
  
  cat >expect << EOF
   M dir1/modified
@@@ -400,8 -396,7 +397,7 @@@ test_expect_success 'status -unormal' 
  '
  
  test_expect_success 'status (status.showUntrackedFiles normal)' '
-       git config status.showuntrackedfiles normal
-       test_when_finished "git config --unset status.showuntrackedfiles" &&
+       test_config status.showuntrackedfiles normal
        git status >output &&
        test_i18ncmp expect output
  '
@@@ -459,8 -454,7 +455,7 @@@ test_expect_success 'status -uall' 
  '
  
  test_expect_success 'status (status.showUntrackedFiles all)' '
-       git config status.showuntrackedfiles all
-       test_when_finished "git config --unset status.showuntrackedfiles" &&
+       test_config status.showuntrackedfiles all
        git status >output &&
        test_i18ncmp expect output
  '
@@@ -485,10 -479,9 +480,9 @@@ test_expect_success 'status -s -uall' 
        test_cmp expect output
  '
  test_expect_success 'status -s (status.showUntrackedFiles all)' '
-       git config status.showuntrackedfiles all
+       test_config status.showuntrackedfiles all &&
        git status -s >output &&
        rm -rf dir3 &&
-       git config --unset status.showuntrackedfiles &&
        test_cmp expect output
  '
  
@@@ -588,15 -581,13 +582,13 @@@ cat >expect <<\EO
  EOF
  
  test_expect_success 'status with color.ui' '
-       git config color.ui always &&
-       test_when_finished "git config --unset color.ui" &&
+       test_config color.ui always &&
        git status | test_decode_color >output &&
        test_i18ncmp expect output
  '
  
  test_expect_success 'status with color.status' '
-       git config color.status always &&
-       test_when_finished "git config --unset color.status" &&
+       test_config color.status always &&
        git status | test_decode_color >output &&
        test_i18ncmp expect output
  '
@@@ -720,8 -711,7 +712,7 @@@ EO
  
  test_expect_success 'status without relative paths' '
  
-       git config status.relativePaths false &&
-       test_when_finished "git config --unset status.relativePaths" &&
+       test_config status.relativePaths false &&
        (cd dir1 && git status) >output &&
        test_i18ncmp expect output
  
@@@ -740,8 -730,7 +731,7 @@@ EO
  
  test_expect_success 'status -s without relative paths' '
  
-       git config status.relativePaths false &&
-       test_when_finished "git config --unset status.relativePaths" &&
+       test_config status.relativePaths false &&
        (cd dir1 && git status -s) >output &&
        test_cmp expect output
  
@@@ -1038,15 -1027,14 +1028,14 @@@ test_expect_success '--ignore-submodule
  '
  
  test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
-       git config diff.ignoreSubmodules dirty &&
+       test_config diff.ignoreSubmodules dirty &&
        git status >output &&
        test_i18ncmp expect output &&
        git config --add -f .gitmodules submodule.subname.ignore untracked &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status >output &&
        test_i18ncmp expect output &&
-       git config -f .gitmodules  --remove-section submodule.subname &&
-       git config --unset diff.ignoreSubmodules
+       git config -f .gitmodules  --remove-section submodule.subname
  '
  
  test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
@@@ -1066,15 -1054,14 +1055,14 @@@ test_expect_success '--ignore-submodule
  '
  
  test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
-       git config diff.ignoreSubmodules dirty &&
+       test_config diff.ignoreSubmodules dirty &&
        git status >output &&
        ! test -s actual &&
        git config --add -f .gitmodules submodule.subname.ignore dirty &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status >output &&
        test_i18ncmp expect output &&
-       git config -f .gitmodules  --remove-section submodule.subname &&
-       git config --unset diff.ignoreSubmodules
+       git config -f .gitmodules  --remove-section submodule.subname
  '
  
  test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
@@@ -1291,15 -1278,13 +1279,13 @@@ cat > expect << EO
  EOF
  
  test_expect_success "status (core.commentchar with submodule summary)" '
-       test_when_finished "git config --unset core.commentchar" &&
-       git config core.commentchar ";" &&
+       test_config core.commentchar ";" &&
        git status >output &&
        test_i18ncmp expect output
  '
  
  test_expect_success "status (core.commentchar with two chars with submodule summary)" '
-       test_when_finished "git config --unset core.commentchar" &&
-       git config core.commentchar ";;" &&
+       test_config core.commentchar ";;" &&
        git status >output &&
        test_i18ncmp expect output
  '