Merge branch 'dt/tests-with-env-not-subshell'
authorJunio C Hamano <gitster@pobox.com>
Mon, 31 Mar 2014 23:30:40 +0000 (16:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 31 Mar 2014 23:30:40 +0000 (16:30 -0700)
* dt/tests-with-env-not-subshell:
tests: use "env" to run commands with temporary env-var settings

1  2 
t/t1300-repo-config.sh
t/t3200-branch.sh
t/t3301-notes.sh
t/t5801-remote-helpers.sh
diff --combined t/t1300-repo-config.sh
index c9c426c273e556302338f7a30fc46de64b856eb2,cd23d070291166d67f5b30adcba358e5958c80a5..3e3f77b59b797bf1f3f1e0eff7c608ac6ab5b6dd
@@@ -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 &&
        (
@@@ -974,24 -961,15 +974,15 @@@ test_expect_success SYMLINKS 'symlinke
  '
  
  test_expect_success 'nonexistent configuration' '
-       (
-               GIT_CONFIG=doesnotexist &&
-               export GIT_CONFIG &&
-               test_must_fail git config --list &&
-               test_must_fail git config test.xyzzy
-       )
+       test_must_fail env GIT_CONFIG=doesnotexist git config --list &&
+       test_must_fail env GIT_CONFIG=doesnotexist git config test.xyzzy
  '
  
  test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
        ln -s doesnotexist linktonada &&
        ln -s linktonada linktolinktonada &&
-       (
-               GIT_CONFIG=linktonada &&
-               export GIT_CONFIG &&
-               test_must_fail git config --list &&
-               GIT_CONFIG=linktolinktonada &&
-               test_must_fail git config --list
-       )
+       test_must_fail env GIT_CONFIG=linktonada git config --list &&
+       test_must_fail env GIT_CONFIG=linktolinktonada git config --list
  '
  
  test_expect_success 'check split_cmdline return' "
diff --combined t/t3200-branch.sh
index 83037b1cd94046ea1ec82819b7d30790b28634d2,d45e95cfec85ec712f1a85a499641b1f5f1595bc..ac31b711f29139470308d9062fea33259cf004ab
@@@ -507,16 -507,6 +507,16 @@@ EO
        test_cmp expected actual
  '
  
 +test_expect_success '--set-upstream-to notices an error to set branch as own upstream' '
 +      git branch --set-upstream-to refs/heads/my13 my13 2>actual &&
 +      cat >expected <<-\EOF &&
 +      warning: Not setting branch my13 as its own upstream.
 +      EOF
 +      test_expect_code 1 git config branch.my13.remote &&
 +      test_expect_code 1 git config branch.my13.merge &&
 +      test_i18ncmp expected actual
 +'
 +
  # Keep this test last, as it changes the current branch
  cat >expect <<EOF
  $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000       branch: Created from master
@@@ -859,11 -849,7 +859,7 @@@ test_expect_success 'detect typo in bra
        write_script editor <<-\EOF &&
                echo "New contents" >"$1"
        EOF
-       (
-               EDITOR=./editor &&
-               export EDITOR &&
-               test_must_fail git branch --edit-description no-such-branch
-       )
+       test_must_fail env EDITOR=./editor git branch --edit-description no-such-branch
  '
  
  test_expect_success 'refuse --edit-description on unborn branch for now' '
                echo "New contents" >"$1"
        EOF
        git checkout --orphan unborn &&
-       (
-               EDITOR=./editor &&
-               export EDITOR &&
-               test_must_fail git branch --edit-description
-       )
+       test_must_fail env EDITOR=./editor git branch --edit-description
  '
  
  test_expect_success '--merged catches invalid object names' '
diff --combined t/t3301-notes.sh
index 3bb79a47af5e2f619753c61436ec577ec025a8ae,bf52db239a390462cf9aab9f0582a321e13036a5..cfd67ff3dfc64b160bbc53318df3eb661970f2e1
@@@ -17,7 -17,7 +17,7 @@@ GIT_EDITOR=./fake_editor.s
  export GIT_EDITOR
  
  test_expect_success 'cannot annotate non-existing HEAD' '
-       (MSG=3 && export MSG && test_must_fail git notes add)
+       test_must_fail env MSG=3 git notes add
  '
  
  test_expect_success setup '
  '
  
  test_expect_success 'need valid notes ref' '
-       (MSG=1 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
-        test_must_fail git notes add) &&
-       (MSG=2 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
-        test_must_fail git notes show)
+       test_must_fail env MSG=1 GIT_NOTES_REF=/ git notes show &&
+       test_must_fail env MSG=2 GIT_NOTES_REF=/ git notes show
  '
  
  test_expect_success 'refusing to add notes in refs/heads/' '
-       (MSG=1 GIT_NOTES_REF=refs/heads/bogus &&
-        export MSG GIT_NOTES_REF &&
-        test_must_fail git notes add)
+       test_must_fail env MSG=1 GIT_NOTES_REF=refs/heads/bogus git notes add
  '
  
  test_expect_success 'refusing to edit notes in refs/remotes/' '
-       (MSG=1 GIT_NOTES_REF=refs/remotes/bogus &&
-        export MSG GIT_NOTES_REF &&
-        test_must_fail git notes edit)
+       test_must_fail env MSG=1 GIT_NOTES_REF=refs/heads/bogus git notes edit
  '
  
  # 1 indicates caught gracefully by die, 128 means git-show barked
@@@ -812,33 -806,6 +806,33 @@@ test_expect_success 'create note from n
        test_must_fail git notes list HEAD
  '
  
 +test_expect_success 'create note from non-blob with "git notes add -C" fails' '
 +      commit=$(git rev-parse --verify HEAD) &&
 +      tree=$(git rev-parse --verify HEAD:) &&
 +      test_must_fail git notes add -C $commit &&
 +      test_must_fail git notes add -C $tree &&
 +      test_must_fail git notes list HEAD
 +'
 +
 +cat > expect << EOF
 +commit 80d796defacd5db327b7a4e50099663902fbdc5c
 +Author: A U Thor <author@example.com>
 +Date:   Thu Apr 7 15:20:13 2005 -0700
 +
 +    8th
 +
 +Notes (other):
 +    This is a blob object
 +EOF
 +
 +test_expect_success 'create note from blob with "git notes add -C" reuses blob id' '
 +      blob=$(echo "This is a blob object" | git hash-object -w --stdin) &&
 +      git notes add -C $blob &&
 +      git log -1 > actual &&
 +      test_cmp expect actual &&
 +      test "$(git notes list HEAD)" = "$blob"
 +'
 +
  cat > expect << EOF
  commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
  Author: A U Thor <author@example.com>
@@@ -865,11 -832,7 +859,7 @@@ test_expect_success 'create note from n
        git add a10 &&
        test_tick &&
        git commit -m 10th &&
-       (
-               MSG="yet another note" &&
-               export MSG &&
-               test_must_fail git notes add -c deadbeef
-       ) &&
+       test_must_fail env MSG="yet another note" git notes add -c deadbeef &&
        test_must_fail git notes list HEAD
  '
  
index c33cc25805d2a913725355a183118a0dd5547800,ca1983827007738e5c8b0dec4a02f13631aaa75b..25fd2e7f46cb559372125e08671445476cbf6022
@@@ -94,19 -94,6 +94,19 @@@ test_expect_failure 'push new branch wi
        compare_refs local HEAD server refs/heads/new-refspec
  '
  
 +test_expect_success 'forced push' '
 +      (cd local &&
 +      git checkout -b force-test &&
 +      echo content >> file &&
 +      git commit -a -m eight &&
 +      git push origin force-test &&
 +      echo content >> file &&
 +      git commit -a --amend -m eight-modified &&
 +      git push --force origin force-test
 +      ) &&
 +      compare_refs local refs/heads/force-test server refs/heads/force-test
 +'
 +
  test_expect_success 'cloning without refspec' '
        GIT_REMOTE_TESTGIT_REFSPEC="" \
        git clone "testgit::${PWD}/server" local2 2>error &&
@@@ -231,10 -218,8 +231,8 @@@ test_expect_success 'proper failure che
  '
  
  test_expect_success 'proper failure checks for pushing' '
-       (GIT_REMOTE_TESTGIT_FAILURE=1 &&
-       export GIT_REMOTE_TESTGIT_FAILURE &&
-       cd local &&
-       test_must_fail git push --all
+       (cd local &&
+       test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all
        )
  '