Merge branch 'jk/tests-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Mon, 31 Mar 2014 23:31:17 +0000 (16:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 31 Mar 2014 23:31:17 +0000 (16:31 -0700)
* jk/tests-cleanup:
t0001: drop subshells just for "cd"
t0001: drop useless subshells
t0001: use test_must_fail
t0001: use test_config_global
t0001: use test_path_is_*
t0001: make symlink reinit test more careful
t: prefer "git config --file" to GIT_CONFIG
t: prefer "git config --file" to GIT_CONFIG with test_must_fail
t: stop using GIT_CONFIG to cross repo boundaries
t: drop useless sane_unset GIT_* calls
t/test-lib: drop redundant unset of GIT_CONFIG
t/Makefile: stop setting GIT_CONFIG

1  2 
t/t1300-repo-config.sh
t/test-lib.sh
diff --combined t/t1300-repo-config.sh
index 3e3f77b59b797bf1f3f1e0eff7c608ac6ab5b6dd,85c66370081bcb31dece9e3af3f6acb6bada1b50..58cd5435be59107c3bac323e0d53816ab0f8e4ae
@@@ -461,7 -461,7 +461,7 @@@ test_expect_success 'new variable inser
        test_cmp expect .git/config
  '
  
- test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' '
+ test_expect_success 'alternative --file (non-existing file should fail)' '
        test_must_fail git config --file non-existing-config -l
  '
  
@@@ -475,28 -475,15 +475,28 @@@ ein.bahn=strass
  EOF
  
  test_expect_success 'alternative GIT_CONFIG' '
 -      GIT_CONFIG=other-config git config -l >output &&
 +      GIT_CONFIG=other-config git config --list >output &&
        test_cmp expect output
  '
  
  test_expect_success 'alternative GIT_CONFIG (--file)' '
 -      git config --file other-config -l > output &&
 +      git config --file other-config --list >output &&
        test_cmp expect output
  '
  
 +test_expect_success 'alternative GIT_CONFIG (--file=-)' '
 +      git config --file - --list <other-config >output &&
 +      test_cmp expect output
 +'
 +
 +test_expect_success 'setting a value in stdin is an error' '
 +      test_must_fail git config --file - some.value foo
 +'
 +
 +test_expect_success 'editing stdin is an error' '
 +      test_must_fail git config --file - --edit
 +'
 +
  test_expect_success 'refer config from subdirectory' '
        mkdir x &&
        (
  
  '
  
- test_expect_success 'refer config from subdirectory via GIT_CONFIG' '
+ test_expect_success 'refer config from subdirectory via --file' '
        (
                cd x &&
-               GIT_CONFIG=../other-config git config --get ein.bahn >actual &&
+               git config --file=../other-config --get ein.bahn >actual &&
                test_cmp expect actual
        )
  '
@@@ -523,8 -510,8 +523,8 @@@ cat > expect << EO
        park = ausweis
  EOF
  
- test_expect_success '--set in alternative GIT_CONFIG' '
-       GIT_CONFIG=other-config git config anwohner.park ausweis &&
+ test_expect_success '--set in alternative file' '
+       git config --file=other-config anwohner.park ausweis &&
        test_cmp expect other-config
  '
  
@@@ -955,11 -942,11 +955,11 @@@ test_expect_success 'inner whitespace k
  
  test_expect_success SYMLINKS 'symlinked configuration' '
        ln -s notyet myconfig &&
-       GIT_CONFIG=myconfig git config test.frotz nitfol &&
+       git config --file=myconfig test.frotz nitfol &&
        test -h myconfig &&
        test -f notyet &&
-       test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol &&
-       GIT_CONFIG=myconfig git config test.xyzzy rezrov &&
+       test "z$(git config --file=notyet test.frotz)" = znitfol &&
+       git config --file=myconfig test.xyzzy rezrov &&
        test -h myconfig &&
        test -f notyet &&
        cat >expect <<-\EOF &&
        rezrov
        EOF
        {
-               GIT_CONFIG=notyet git config test.frotz &&
-               GIT_CONFIG=notyet git config test.xyzzy
+               git config --file=notyet test.frotz &&
+               git config --file=notyet test.xyzzy
        } >actual &&
        test_cmp expect actual
  '
  
  test_expect_success 'nonexistent configuration' '
-       test_must_fail env GIT_CONFIG=doesnotexist git config --list &&
-       test_must_fail env GIT_CONFIG=doesnotexist git config test.xyzzy
+       test_must_fail git config --file=doesnotexist --list &&
+       test_must_fail git config --file=doesnotexist test.xyzzy
  '
  
  test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
        ln -s doesnotexist linktonada &&
        ln -s linktonada linktolinktonada &&
-       test_must_fail env GIT_CONFIG=linktonada git config --list &&
-       test_must_fail env GIT_CONFIG=linktolinktonada git config --list
+       test_must_fail git config --file=linktonada --list &&
+       test_must_fail git config --file=linktolinktonada --list
  '
  
  test_expect_success 'check split_cmdline return' "
diff --combined t/test-lib.sh
index 87f327ff8bcd2c2a29fcbabe74c226232b54f728,625f06e5e5080eb5ac9d34ee0526d7eccde3e9cc..c081668dfe16c85dda29bace564f7c1c3da77cb0
@@@ -108,12 -108,6 +108,12 @@@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAM
  export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
  export EDITOR
  
 +if test -n "${TEST_GIT_INDEX_VERSION:+isset}"
 +then
 +      GIT_INDEX_VERSION="$TEST_GIT_INDEX_VERSION"
 +      export GIT_INDEX_VERSION
 +fi
 +
  # Add libc MALLOC and MALLOC_PERTURB test
  # only if we are not executing the test with valgrind
  if expr " $GIT_TEST_OPTS " : ".* --valgrind " >/dev/null ||
@@@ -283,7 -277,7 +283,7 @@@ error "Test script did not set test_des
  
  if test "$help" = "t"
  then
 -      echo "$test_description"
 +      printf '%s\n' "$test_description"
        exit 0
  fi
  
@@@ -334,7 -328,7 +334,7 @@@ test_failure_ () 
        test_failure=$(($test_failure + 1))
        say_color error "not ok $test_count - $1"
        shift
 -      echo "$@" | sed -e 's/^/#       /'
 +      printf '%s\n' "$*" | sed -e 's/^/#      /'
        test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
  }
  
@@@ -655,7 -649,6 +655,6 @@@ else # normal case, use ../bin-wrapper
        fi
  fi
  GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
- unset GIT_CONFIG
  GIT_CONFIG_NOSYSTEM=1
  GIT_ATTR_NOSYSTEM=1
  export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM