Merge branch 'en/and-cascade-tests'
authorJunio C Hamano <gitster@pobox.com>
Wed, 24 Nov 2010 23:51:49 +0000 (15:51 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Nov 2010 23:51:49 +0000 (15:51 -0800)
* en/and-cascade-tests: (25 commits)
t4124 (apply --whitespace): use test_might_fail
t3404: do not use 'describe' to implement test_cmp_rev
t3404 (rebase -i): introduce helper to check position of HEAD
t3404 (rebase -i): move comment to description
t3404 (rebase -i): unroll test_commit loops
t3301 (notes): use test_expect_code for clarity
t1400 (update-ref): use test_must_fail
t1502 (rev-parse --parseopt): test exit code from "-h"
t6022 (renaming merge): chain test commands with &&
test-lib: introduce test_line_count to measure files
tests: add missing &&, batch 2
tests: add missing &&
Introduce sane_unset and use it to ensure proper && chaining
t7800 (difftool): add missing &&
t7601 (merge-pull-config): add missing &&
t7001 (mv): add missing &&
t6016 (rev-list-graph-simplify-history): add missing &&
t5602 (clone-remote-exec): add missing &&
t4026 (color): remove unneeded and unchained command
t4019 (diff-wserror): add lots of missing &&
...

Conflicts:
t/t7006-pager.sh

14 files changed:
1  2 
t/README
t/annotate-tests.sh
t/t0003-attributes.sh
t/t1011-read-tree-sparse-checkout.sh
t/t4015-diff-whitespace.sh
t/t4034-diff-words.sh
t/t4103-apply-binary.sh
t/t5503-tagfollow.sh
t/t556x_common
t/t7004-tag.sh
t/t7006-pager.sh
t/t7810-grep.sh
t/t9300-fast-import.sh
t/test-lib.sh
diff --combined t/README
index c548bf1b7eb17b861d8f26bd2381ed6bbae2aa52,1a78982da1265242d7fa5f249eaa2f67ae9d2879..892d443f63428aea6d6b92458bdaa4575bc46da0
+++ b/t/README
@@@ -50,12 -50,6 +50,12 @@@ prove and other harnesses come with a l
      # Repeat until no more failures
      $ prove -j 15 --state=failed,save ./t[0-9]*.sh
  
 +You can give DEFAULT_TEST_TARGET=prove on the make command (or define it
 +in config.mak) to cause "make test" to run tests under prove.
 +GIT_PROVE_OPTS can be used to pass additional options, e.g.
 +
 +    $ make DEFAULT_TEST_TARGET=prove GIT_PROVE_OPTS='--timer --jobs 16' test
 +
  You can also run each test individually from command line, like this:
  
      $ sh ./t3010-ls-files-killed-modified.sh
@@@ -265,14 -259,11 +265,11 @@@ Do
        test ...
  
     That way all of the commands in your tests will succeed or fail. If
-    you must ignore the return value of something (e.g., the return
-    after unsetting a variable that was already unset is unportable) it's
-    best to indicate so explicitly with a semicolon:
-       unset HLAGH;
-       git merge hla &&
-       git push gh &&
-       test ...
+    you must ignore the return value of something, consider using a
+    helper function (e.g. use sane_unset instead of unset, in order
+    to avoid unportable return value for unsetting a variable that was
+    already unset), or prepending the command with test_might_fail or
+    test_must_fail.
  
   - Check the test coverage for your tests. See the "Test coverage"
     below.
@@@ -401,13 -392,6 +398,6 @@@ library for your script to use
     Like test_expect_success this function can optionally use a three
     argument invocation with a prerequisite as the first argument.
  
-  - test_expect_code [<prereq>] <code> <message> <script>
-    Analogous to test_expect_success, but pass the test if it exits
-    with a given exit <code>
-  test_expect_code 1 'Merge with d/f conflicts' 'git merge "merge msg" B master'
   - test_debug <script>
  
     This takes a single argument, <script>, and evaluates it only
            'Perl API' \
            "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl
  
+  - test_expect_code <exit-code> <command>
+    Run a command and ensure that it exits with the given exit code.
+    For example:
+       test_expect_success 'Merge with d/f conflicts' '
+               test_expect_code 1 git merge "merge msg" B master
+       '
   - test_must_fail <git-command>
  
     Run a git command and ensure it fails in a controlled way.  Use
     <expected> file.  This behaves like "cmp" but produces more
     helpful output when the test is run with "-v" option.
  
+  - test_line_count (= | -lt | -ge | ...) <length> <file>
+    Check whether a file has the length it is expected to.
   - test_path_is_file <file> [<diagnosis>]
     test_path_is_dir <dir> [<diagnosis>]
     test_path_is_missing <path> [<diagnosis>]
diff --combined t/annotate-tests.sh
index 141b60cdcbf4c8f70813e090a950c5d736853a8e,35353fae0a3fa8d5bffd5d390e15b126df5c62bc..212bd605b5193d26c38efda3bb2ed9fd95b8b462
@@@ -8,27 -8,27 +8,27 @@@ check_count () 
        $PROG file $head >.result || return 1
        cat .result | perl -e '
                my %expect = (@ARGV);
 -              my %count = ();
 +              my %count = map { $_ => 0 } keys %expect;
                while (<STDIN>) {
                        if (/^[0-9a-f]+\t\(([^\t]+)\t/) {
                                my $author = $1;
                                for ($author) { s/^\s*//; s/\s*$//; }
 -                              if (exists $expect{$author}) {
 -                                      $count{$author}++;
 -                              }
 +                              $count{$author}++;
                        }
                }
                my $bad = 0;
                while (my ($author, $count) = each %count) {
                        my $ok;
 -                      if ($expect{$author} != $count) {
 +                      my $value = 0;
 +                      $value = $expect{$author} if defined $expect{$author};
 +                      if ($value != $count) {
                                $bad = 1;
                                $ok = "bad";
                        }
                        else {
                                $ok = "good";
                        }
 -                      print STDERR "Author $author (expected $expect{$author}, attributed $count) $ok\n";
 +                      print STDERR "Author $author (expected $value, attributed $count) $ok\n";
                }
                exit($bad);
        ' "$@"
@@@ -38,7 -38,7 +38,7 @@@ test_expect_success 
      'prepare reference tree' \
      'echo "1A quick brown fox jumps over the" >file &&
       echo "lazy dog" >>file &&
-      git add file
+      git add file &&
       GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
  
  test_expect_success \
diff --combined t/t0003-attributes.sh
index e75153bdea05d2e34570aaf03fbb3902694ddedf,7590b453db0503556c53962a2e44071a13c3d96e..ebbc7554a7d4dce4c2ed33a79f5d4feb3a520f05
@@@ -36,9 -36,6 +36,9 @@@ test_expect_success 'setup' 
                echo "d/* test=a/b/d/*"
                echo "d/yes notest"
        ) >a/b/.gitattributes
 +      (
 +              echo "global test=global"
 +      ) >"$HOME"/global-gitattributes
  
  '
  
@@@ -60,19 -57,9 +60,19 @@@ test_expect_success 'attribute test' 
  
  '
  
 +test_expect_success 'core.attributesfile' '
 +      attr_check global unspecified &&
 +      git config core.attributesfile "$HOME/global-gitattributes" &&
 +      attr_check global global &&
 +      git config core.attributesfile "~/global-gitattributes" &&
 +      attr_check global global &&
 +      echo "global test=precedence" >> .gitattributes &&
 +      attr_check global precedence
 +'
 +
  test_expect_success 'attribute test: read paths from stdin' '
  
-       cat <<EOF > expect
+       cat <<EOF > expect &&
  f: test: f
  a/f: test: f
  a/c/f: test: f
index 8008fa2d894baf76a19168a020ed4f4640619ce7,8cf151548a6a758e49566ae7ff0d71107c9c41f5..0ef11bccb4a84b508b217d5d2bf4ef13c2d13282
@@@ -17,19 -17,17 +17,19 @@@ test_expect_success 'setup' 
        cat >expected <<-\EOF &&
        100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0       init.t
        100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       sub/added
 +      100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       subsub/added
        EOF
        cat >expected.swt <<-\EOF &&
        H init.t
        H sub/added
 +      H subsub/added
        EOF
  
        test_commit init &&
        echo modified >>init.t &&
 -      mkdir sub &&
 -      touch sub/added &&
 -      git add init.t sub/added &&
 +      mkdir sub subsub &&
 +      touch sub/added subsub/added &&
 +      git add init.t sub/added subsub/added &&
        git commit -m "modified and added" &&
        git tag top &&
        git rm sub/added &&
@@@ -49,7 -47,7 +49,7 @@@ test_expect_success 'read-tree without 
  '
  
  test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
-       echo >.git/info/sparse-checkout
+       echo >.git/info/sparse-checkout &&
        git read-tree -m -u HEAD &&
        git ls-files -t >result &&
        test_cmp expected.swt result &&
@@@ -83,7 -81,6 +83,7 @@@ test_expect_success 'match directories 
        cat >expected.swt-noinit <<-\EOF &&
        S init.t
        H sub/added
 +      S subsub/added
        EOF
  
        echo sub/ > .git/info/sparse-checkout &&
@@@ -108,7 -105,6 +108,7 @@@ test_expect_success 'checkout area chan
        cat >expected.swt-nosub <<-\EOF &&
        H init.t
        S sub/added
 +      S subsub/added
        EOF
  
        echo init.t >.git/info/sparse-checkout &&
index a8736f7cbeef65b3454847bb4b4df508c0079652,88c6b5bdcbd1df287edfe42bc06804cdb98574f5..8622eb51c70acf73ea1f2173a946b1a5ade6a221
@@@ -330,7 -330,7 +330,7 @@@ test_expect_success 'check space befor
  
  test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
  
-       git config core.whitespace "-indent-with-non-tab"
+       git config core.whitespace "-indent-with-non-tab" &&
        echo "        foo ();" > x &&
        git diff --check
  
@@@ -491,41 -491,4 +491,41 @@@ test_expect_success 'combined diff wit
  
  '
  
 +# Start testing the colored format for whitespace checks
 +
 +test_expect_success 'setup diff colors' '
 +      git config color.diff always &&
 +      git config color.diff.plain normal &&
 +      git config color.diff.meta bold &&
 +      git config color.diff.frag cyan &&
 +      git config color.diff.func normal &&
 +      git config color.diff.old red &&
 +      git config color.diff.new green &&
 +      git config color.diff.commit yellow &&
 +      git config color.diff.whitespace "normal red" &&
 +
 +      git config core.autocrlf false
 +'
 +cat >expected <<\EOF
 +<BOLD>diff --git a/x b/x<RESET>
 +<BOLD>index 9daeafb..2874b91 100644<RESET>
 +<BOLD>--- a/x<RESET>
 +<BOLD>+++ b/x<RESET>
 +<CYAN>@@ -1 +1,4 @@<RESET>
 + test<RESET>
 +<GREEN>+<RESET><GREEN>{<RESET>
 +<GREEN>+<RESET><BRED> <RESET>
 +<GREEN>+<RESET><GREEN>}<RESET>
 +EOF
 +
 +test_expect_success 'diff that introduces a line with only tabs' '
 +      git config core.whitespace blank-at-eol &&
 +      git reset --hard &&
 +      echo "test" > x &&
 +      git commit -m "initial" x &&
 +      echo "{NTN}" | tr "NT" "\n\t" >> x &&
 +      git -c color.diff=always diff | test_decode_color >current &&
 +      test_cmp expected current
 +'
 +
  test_done
diff --combined t/t4034-diff-words.sh
index 3f3c7577ca85c92e5ff986044e0c4afa95bf608d,483f6a01ca47f07d28a154237679a6d3d571c770..8096d8a337867b4afdc4b061fdc314fdd8eac185
@@@ -6,8 -6,8 +6,8 @@@ test_description='word diff colors
  
  test_expect_success setup '
  
-       git config diff.color.old red
-       git config diff.color.new green
+       git config diff.color.old red &&
+       git config diff.color.new green &&
        git config diff.color.func magenta
  
  '
@@@ -35,10 -35,10 +35,10 @@@ aeff = aeff * ( aaa 
  EOF
  
  cat > expect <<\EOF
 -<WHITE>diff --git a/pre b/post<RESET>
 -<WHITE>index 330b04f..5ed8eff 100644<RESET>
 -<WHITE>--- a/pre<RESET>
 -<WHITE>+++ b/post<RESET>
 +<BOLD>diff --git a/pre b/post<RESET>
 +<BOLD>index 330b04f..5ed8eff 100644<RESET>
 +<BOLD>--- a/pre<RESET>
 +<BOLD>+++ b/post<RESET>
  <CYAN>@@ -1,3 +1,7 @@<RESET>
  <RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
  
@@@ -122,10 -122,10 +122,10 @@@ test_expect_success '--word-diff=plain 
  '
  
  cat > expect <<EOF
 -<WHITE>diff --git a/pre b/post<RESET>
 -<WHITE>index 330b04f..5ed8eff 100644<RESET>
 -<WHITE>--- a/pre<RESET>
 -<WHITE>+++ b/post<RESET>
 +<BOLD>diff --git a/pre b/post<RESET>
 +<BOLD>index 330b04f..5ed8eff 100644<RESET>
 +<BOLD>--- a/pre<RESET>
 +<BOLD>+++ b/post<RESET>
  <CYAN>@@ -1,3 +1,7 @@<RESET>
  <RED>[-h(4)-]<RESET><GREEN>{+h(4),hh[44]+}<RESET>
  
@@@ -143,10 -143,10 +143,10 @@@ test_expect_success '--word-diff=plain 
  '
  
  cat > expect <<\EOF
 -<WHITE>diff --git a/pre b/post<RESET>
 -<WHITE>index 330b04f..5ed8eff 100644<RESET>
 -<WHITE>--- a/pre<RESET>
 -<WHITE>+++ b/post<RESET>
 +<BOLD>diff --git a/pre b/post<RESET>
 +<BOLD>index 330b04f..5ed8eff 100644<RESET>
 +<BOLD>--- a/pre<RESET>
 +<BOLD>+++ b/post<RESET>
  <CYAN>@@ -1 +1 @@<RESET>
  <RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
  <CYAN>@@ -3,0 +4,4 @@<RESET> <RESET><MAGENTA>a = b + c<RESET>
@@@ -163,10 -163,10 +163,10 @@@ test_expect_success 'word diff without 
  '
  
  cat > expect <<\EOF
 -<WHITE>diff --git a/pre b/post<RESET>
 -<WHITE>index 330b04f..5ed8eff 100644<RESET>
 -<WHITE>--- a/pre<RESET>
 -<WHITE>+++ b/post<RESET>
 +<BOLD>diff --git a/pre b/post<RESET>
 +<BOLD>index 330b04f..5ed8eff 100644<RESET>
 +<BOLD>--- a/pre<RESET>
 +<BOLD>+++ b/post<RESET>
  <CYAN>@@ -1,3 +1,7 @@<RESET>
  h(4),<GREEN>hh<RESET>[44]
  
@@@ -199,10 -199,10 +199,10 @@@ test_expect_success 'option overrides .
  '
  
  cat > expect <<\EOF
 -<WHITE>diff --git a/pre b/post<RESET>
 -<WHITE>index 330b04f..5ed8eff 100644<RESET>
 -<WHITE>--- a/pre<RESET>
 -<WHITE>+++ b/post<RESET>
 +<BOLD>diff --git a/pre b/post<RESET>
 +<BOLD>index 330b04f..5ed8eff 100644<RESET>
 +<BOLD>--- a/pre<RESET>
 +<BOLD>+++ b/post<RESET>
  <CYAN>@@ -1,3 +1,7 @@<RESET>
  h(4)<GREEN>,hh[44]<RESET>
  
@@@ -231,10 -231,10 +231,10 @@@ test_expect_success 'command-line overr
  '
  
  cat > expect <<\EOF
 -<WHITE>diff --git a/pre b/post<RESET>
 -<WHITE>index 330b04f..5ed8eff 100644<RESET>
 -<WHITE>--- a/pre<RESET>
 -<WHITE>+++ b/post<RESET>
 +<BOLD>diff --git a/pre b/post<RESET>
 +<BOLD>index 330b04f..5ed8eff 100644<RESET>
 +<BOLD>--- a/pre<RESET>
 +<BOLD>+++ b/post<RESET>
  <CYAN>@@ -1,3 +1,7 @@<RESET>
  h(4),<GREEN>{+hh+}<RESET>[44]
  
@@@ -260,10 -260,10 +260,10 @@@ test_expect_success 'remove diff drive
  '
  
  cat > expect <<\EOF
 -<WHITE>diff --git a/pre b/post<RESET>
 -<WHITE>index 330b04f..5ed8eff 100644<RESET>
 -<WHITE>--- a/pre<RESET>
 -<WHITE>+++ b/post<RESET>
 +<BOLD>diff --git a/pre b/post<RESET>
 +<BOLD>index 330b04f..5ed8eff 100644<RESET>
 +<BOLD>--- a/pre<RESET>
 +<BOLD>+++ b/post<RESET>
  <CYAN>@@ -1,3 +1,7 @@<RESET>
  h(4),<GREEN>hh[44<RESET>]
  
@@@ -282,10 -282,10 +282,10 @@@ echo 'aaa (aaa)' > pr
  echo 'aaa (aaa) aaa' > post
  
  cat > expect <<\EOF
 -<WHITE>diff --git a/pre b/post<RESET>
 -<WHITE>index c29453b..be22f37 100644<RESET>
 -<WHITE>--- a/pre<RESET>
 -<WHITE>+++ b/post<RESET>
 +<BOLD>diff --git a/pre b/post<RESET>
 +<BOLD>index c29453b..be22f37 100644<RESET>
 +<BOLD>--- a/pre<RESET>
 +<BOLD>+++ b/post<RESET>
  <CYAN>@@ -1 +1 @@<RESET>
  aaa (aaa) <GREEN>aaa<RESET>
  EOF
@@@ -301,10 -301,10 +301,10 @@@ echo '(:' > pr
  echo '(' > post
  
  cat > expect <<\EOF
 -<WHITE>diff --git a/pre b/post<RESET>
 -<WHITE>index 289cb9d..2d06f37 100644<RESET>
 -<WHITE>--- a/pre<RESET>
 -<WHITE>+++ b/post<RESET>
 +<BOLD>diff --git a/pre b/post<RESET>
 +<BOLD>index 289cb9d..2d06f37 100644<RESET>
 +<BOLD>--- a/pre<RESET>
 +<BOLD>+++ b/post<RESET>
  <CYAN>@@ -1 +1 @@<RESET>
  (<RED>:<RESET>
  EOF
diff --combined t/t4103-apply-binary.sh
index 08ad6d8b9e6b2869bfd2b574779380895709972d,954118c83cf9078d2747b91866661535bc4a2979..dbbf56cba9f5108f79d767ad48f3092dc821a232
@@@ -37,24 -37,15 +37,24 @@@ test_expect_success 'setup' 
        git diff-tree -p -C master binary >C.diff &&
  
        git diff-tree -p --binary master binary >BF.diff &&
 -      git diff-tree -p --binary -C master binary >CF.diff
 +      git diff-tree -p --binary -C master binary >CF.diff &&
 +
 +      git diff-tree -p --full-index master binary >B-index.diff &&
 +      git diff-tree -p -C --full-index master binary >C-index.diff &&
 +
 +      git init other-repo &&
 +      (cd other-repo &&
 +       git fetch .. master &&
 +       git reset --hard FETCH_HEAD
 +      )
  "
  
  test_expect_success 'stat binary diff -- should not fail.' \
-       'git checkout master
+       'git checkout master &&
         git apply --stat --summary B.diff'
  
  test_expect_success 'stat binary diff (copy) -- should not fail.' \
-       'git checkout master
+       'git checkout master &&
         git apply --stat --summary C.diff'
  
  test_expect_success 'check binary diff -- should fail.' \
@@@ -78,11 -69,11 +78,11 @@@ test_expect_success 
  '
  
  test_expect_success 'check binary diff with replacement.' \
-       'git checkout master
+       'git checkout master &&
         git apply --check --allow-binary-replacement BF.diff'
  
  test_expect_success 'check binary diff with replacement (copy).' \
-       'git checkout master
+       'git checkout master &&
         git apply --check --allow-binary-replacement CF.diff'
  
  # Now we start applying them.
@@@ -109,22 -100,6 +109,22 @@@ test_expect_success 'apply binary diff 
        'do_reset &&
         test_must_fail git apply --index C.diff'
  
 +test_expect_success 'apply binary diff with full-index' '
 +      do_reset &&
 +      git apply B-index.diff
 +'
 +
 +test_expect_success 'apply binary diff with full-index (copy)' '
 +      do_reset &&
 +      git apply C-index.diff
 +'
 +
 +test_expect_success 'apply full-index binary diff in new repo' '
 +      (cd other-repo &&
 +       do_reset &&
 +       test_must_fail git apply ../B-index.diff)
 +'
 +
  test_expect_success 'apply binary diff without replacement.' \
        'do_reset &&
         git apply BF.diff'
diff --combined t/t5503-tagfollow.sh
index aa0ada01476b89f3f284dda42f892155496f3467,7f6d3d2f6cfdc9b56f87348639f9128304fb2cb0..60de2d6ede958e713aebe85d73ee65ddbc10201d
@@@ -4,9 -4,14 +4,9 @@@ test_description='test automatic tag fo
  
  . ./test-lib.sh
  
 -case $(uname -s) in
 -*MINGW*)
 +if ! test_have_prereq NOT_MINGW; then
        say "GIT_DEBUG_SEND_PACK not supported - skipping tests"
 -      ;;
 -*)
 -      test_set_prereq NOT_MINGW
 -      ;;
 -esac
 +fi
  
  # End state of the repository:
  #
@@@ -49,7 -54,7 +49,7 @@@ EO
  '
  
  test_expect_success NOT_MINGW 'fetch A (new commit : 1 connection)' '
-       rm -f $U
+       rm -f $U &&
        (
                cd cloned &&
                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
@@@ -82,7 -87,7 +82,7 @@@ EO
  '
  
  test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
-       rm -f $U
+       rm -f $U &&
        (
                cd cloned &&
                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
@@@ -121,7 -126,7 +121,7 @@@ EO
  '
  
  test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
-       rm -f $U
+       rm -f $U &&
        (
                cd cloned &&
                GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
diff --combined t/t556x_common
index 51287d89d8deb27ae2ae49fec84268422377eb29,03dcfb10c9cbb7821195dacad5230ab9cb7ac382..82926cfdb7b7c6a86ab7d73efdfa327a6be28c83
@@@ -50,72 -50,72 +50,72 @@@ get_static_files() 
  }
  
  SMART=smart
 -export GIT_HTTP_EXPORT_ALL=1
 +GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
  test_expect_success 'direct refs/heads/master not found' '
-       log_div "refs/heads/master"
+       log_div "refs/heads/master" &&
        GET refs/heads/master "404 Not Found"
  '
  test_expect_success 'static file is ok' '
-       log_div "getanyfile default"
+       log_div "getanyfile default" &&
        get_static_files "200 OK"
  '
  SMART=smart_noexport
  unset GIT_HTTP_EXPORT_ALL
  test_expect_success 'no export by default' '
-       log_div "no git-daemon-export-ok"
+       log_div "no git-daemon-export-ok" &&
        get_static_files "404 Not Found"
  '
  test_expect_success 'export if git-daemon-export-ok' '
-       log_div "git-daemon-export-ok"
+       log_div "git-daemon-export-ok" &&
          (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
         touch git-daemon-export-ok
        ) &&
          get_static_files "200 OK"
  '
  SMART=smart
 -export GIT_HTTP_EXPORT_ALL=1
 +GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
  test_expect_success 'static file if http.getanyfile true is ok' '
-       log_div "getanyfile true"
+       log_div "getanyfile true" &&
        config http.getanyfile true &&
        get_static_files "200 OK"
  '
  test_expect_success 'static file if http.getanyfile false fails' '
-       log_div "getanyfile false"
+       log_div "getanyfile false" &&
        config http.getanyfile false &&
        get_static_files "403 Forbidden"
  '
  
  test_expect_success 'http.uploadpack default enabled' '
-       log_div "uploadpack default"
+       log_div "uploadpack default" &&
        GET info/refs?service=git-upload-pack "200 OK"  &&
        POST git-upload-pack 0000 "200 OK"
  '
  test_expect_success 'http.uploadpack true' '
-       log_div "uploadpack true"
+       log_div "uploadpack true" &&
        config http.uploadpack true &&
        GET info/refs?service=git-upload-pack "200 OK" &&
        POST git-upload-pack 0000 "200 OK"
  '
  test_expect_success 'http.uploadpack false' '
-       log_div "uploadpack false"
+       log_div "uploadpack false" &&
        config http.uploadpack false &&
        GET info/refs?service=git-upload-pack "403 Forbidden" &&
        POST git-upload-pack 0000 "403 Forbidden"
  '
  
  test_expect_success 'http.receivepack default disabled' '
-       log_div "receivepack default"
+       log_div "receivepack default" &&
        GET info/refs?service=git-receive-pack "403 Forbidden"  &&
        POST git-receive-pack 0000 "403 Forbidden"
  '
  test_expect_success 'http.receivepack true' '
-       log_div "receivepack true"
+       log_div "receivepack true" &&
        config http.receivepack true &&
        GET info/refs?service=git-receive-pack "200 OK" &&
        POST git-receive-pack 0000 "200 OK"
  '
  test_expect_success 'http.receivepack false' '
-       log_div "receivepack false"
+       log_div "receivepack false" &&
        config http.receivepack false &&
        GET info/refs?service=git-receive-pack "403 Forbidden" &&
        POST git-receive-pack 0000 "403 Forbidden"
diff --combined t/t7004-tag.sh
index 700b556fe886ff8e6927591e4a047542bc00ef83,d05f4210f2577c43c4ebba5f5daae9598a4e255d..f160af3ccc8714700218efcd3b38c216ff7bab43
@@@ -1051,23 -1051,13 +1051,23 @@@ test_expect_success 
  
  test_expect_success \
        'message in editor has initial comment' '
 -      GIT_EDITOR=cat git tag -a initial-comment > actual
 +      ! (GIT_EDITOR=cat git tag -a initial-comment > actual)
 +'
 +
 +test_expect_success \
 +      'message in editor has initial comment: first line' '
        # check the first line --- should be empty
 -      first=$(sed -e 1q <actual) &&
 -      test -z "$first" &&
 +      echo >first.expect &&
 +      sed -e 1q <actual >first.actual &&
 +      test_cmp first.expect first.actual
 +'
 +
 +test_expect_success \
 +      'message in editor has initial comment: remainder' '
        # remove commented lines from the remainder -- should be empty
 -      rest=$(sed -e 1d -e '/^#/d' <actual) &&
 -      test -z "$rest"
 +      >rest.expect
 +      sed -e 1d -e '/^#/d' <actual >rest.actual &&
 +      test_cmp rest.expect rest.actual
  '
  
  get_tag_header reuse $commit commit $time >expect
@@@ -1107,7 -1097,7 +1107,7 @@@ hash1=$(git rev-parse HEAD
  test_expect_success 'creating second commit and tag' '
        echo foo-2.0 >foo &&
        git add foo &&
-       git commit -m second
+       git commit -m second &&
        git tag v2.0
  '
  
  EOF
  
  test_expect_success 'checking that first commit is in all tags (hash)' "
-       git tag -l --contains $hash1 v* >actual
+       git tag -l --contains $hash1 v* >actual &&
        test_cmp expected actual
  "
  
  # other ways of specifying the commit
  test_expect_success 'checking that first commit is in all tags (tag)' "
-       git tag -l --contains v1.0 v* >actual
+       git tag -l --contains v1.0 v* >actual &&
        test_cmp expected actual
  "
  
  test_expect_success 'checking that first commit is in all tags (relative)' "
-       git tag -l --contains HEAD~2 v* >actual
+       git tag -l --contains HEAD~2 v* >actual &&
        test_cmp expected actual
  "
  
@@@ -1152,7 -1142,7 +1152,7 @@@ v2.
  EOF
  
  test_expect_success 'checking that second commit only has one tag' "
-       git tag -l --contains $hash2 v* >actual
+       git tag -l --contains $hash2 v* >actual &&
        test_cmp expected actual
  "
  
@@@ -1161,7 -1151,7 +1161,7 @@@ cat > expected <<EO
  EOF
  
  test_expect_success 'checking that third commit has no tags' "
-       git tag -l --contains $hash3 v* >actual
+       git tag -l --contains $hash3 v* >actual &&
        test_cmp expected actual
  "
  
@@@ -1171,7 -1161,7 +1171,7 @@@ test_expect_success 'creating simple br
        git branch stable v2.0 &&
          git checkout stable &&
        echo foo-3.0 > foo &&
-       git commit foo -m fourth
+       git commit foo -m fourth &&
        git tag v3.0
  '
  
@@@ -1182,7 -1172,7 +1182,7 @@@ v3.
  EOF
  
  test_expect_success 'checking that branch head only has one tag' "
-       git tag -l --contains $hash4 v* >actual
+       git tag -l --contains $hash4 v* >actual &&
        test_cmp expected actual
  "
  
@@@ -1196,7 -1186,7 +1196,7 @@@ v4.
  EOF
  
  test_expect_success 'checking that original branch head has one tag now' "
-       git tag -l --contains $hash3 v* >actual
+       git tag -l --contains $hash3 v* >actual &&
        test_cmp expected actual
  "
  
  EOF
  
  test_expect_success 'checking that initial commit is in all tags' "
-       git tag -l --contains $hash1 v* >actual
+       git tag -l --contains $hash1 v* >actual &&
        test_cmp expected actual
  "
  
  # mixing modes and options:
  
  test_expect_success 'mixing incompatibles modes and options is forbidden' '
-       test_must_fail git tag -a
-       test_must_fail git tag -l -v
-       test_must_fail git tag -n 100
-       test_must_fail git tag -l -m msg
-       test_must_fail git tag -l -F some file
+       test_must_fail git tag -a &&
+       test_must_fail git tag -l -v &&
+       test_must_fail git tag -n 100 &&
+       test_must_fail git tag -l -m msg &&
+       test_must_fail git tag -l -F some file &&
        test_must_fail git tag -v -s
  '
  
diff --combined t/t7006-pager.sh
index 5641b595596ea462ec649c531e7173709a012274,7d00d49d0da6487bec345176411e1f51e712f137..e9d8b9110d3bb14a0c1d5b325b875abce57b3318
@@@ -4,15 -4,44 +4,15 @@@ test_description='Test automatic use o
  
  . ./test-lib.sh
  . "$TEST_DIRECTORY"/lib-pager.sh
 +. "$TEST_DIRECTORY"/lib-terminal.sh
  
  cleanup_fail() {
        echo >&2 cleanup failed
        (exit 1)
  }
  
 -test_expect_success 'set up terminal for tests' '
 -      rm -f stdout_is_tty ||
 -      cleanup_fail &&
 -
 -      if test -t 1
 -      then
 -              >stdout_is_tty
 -      elif
 -              test_have_prereq PERL &&
 -              "$PERL_PATH" "$TEST_DIRECTORY"/t7006/test-terminal.perl \
 -                      sh -c "test -t 1"
 -      then
 -              >test_terminal_works
 -      fi
 -'
 -
 -if test -e stdout_is_tty
 -then
 -      test_terminal() { "$@"; }
 -      test_set_prereq TTY
 -elif test -e test_terminal_works
 -then
 -      test_terminal() {
 -              "$PERL_PATH" "$TEST_DIRECTORY"/t7006/test-terminal.perl "$@"
 -      }
 -      test_set_prereq TTY
 -else
 -      say "# no usable terminal, so skipping some tests"
 -fi
 -
  test_expect_success 'setup' '
-       unset GIT_PAGER GIT_PAGER_IN_USE;
+       sane_unset GIT_PAGER GIT_PAGER_IN_USE &&
        test_might_fail git config --unset core.pager &&
  
        PAGER="cat >paginated.out" &&
@@@ -184,6 -213,11 +184,6 @@@ test_expect_success 'color when writin
        colorful colorful.log
  '
  
 -if test_have_prereq SIMPLEPAGER && test_have_prereq TTY
 -then
 -      test_set_prereq SIMPLEPAGERTTY
 -fi
 -
  # Use this helper to make it easy for the caller of your
  # terminal-using function to specify whether it should fail.
  # If you write
@@@ -219,8 -253,8 +219,8 @@@ parse_args() 
  test_default_pager() {
        parse_args "$@"
  
 -      $test_expectation SIMPLEPAGERTTY "$cmd - default pager is used by default" "
 +      $test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" "
-               unset PAGER GIT_PAGER;
+               sane_unset PAGER GIT_PAGER &&
                test_might_fail git config --unset core.pager &&
                rm -f default_pager_used ||
                cleanup_fail &&
@@@ -243,7 -277,7 +243,7 @@@ test_PAGER_overrides() 
        parse_args "$@"
  
        $test_expectation TTY "$cmd - PAGER overrides default pager" "
-               unset GIT_PAGER;
+               sane_unset GIT_PAGER &&
                test_might_fail git config --unset core.pager &&
                rm -f PAGER_used ||
                cleanup_fail &&
@@@ -271,7 -305,7 +271,7 @@@ test_core_pager() 
        parse_args "$@"
  
        $test_expectation TTY "$cmd - repository-local core.pager setting $used_if_wanted" "
-               unset GIT_PAGER;
+               sane_unset GIT_PAGER &&
                rm -f core.pager_used ||
                cleanup_fail &&
  
@@@ -299,7 -333,7 +299,7 @@@ test_pager_subdir_helper() 
        parse_args "$@"
  
        $test_expectation TTY "$cmd - core.pager $used_if_wanted from subdirectory" "
-               unset GIT_PAGER;
+               sane_unset GIT_PAGER &&
                rm -f core.pager_used &&
                rm -fr sub ||
                cleanup_fail &&
diff --combined t/t7810-grep.sh
index 50658845ca8769e963cfc13b20efb892f1f63cc0,79195e21cb1045b1d145a8f5e21fb4d99e0cd884..c8777589ca1c89825b570cfc05405a39df39aaba
@@@ -324,13 -324,8 +324,13 @@@ test_expect_success 'log grep setup' 
  
        echo a >>file &&
        test_tick &&
 -      git commit -a -m "third"
 +      git commit -a -m "third" &&
  
 +      echo a >>file &&
 +      test_tick &&
 +      GIT_AUTHOR_NAME="Night Fall" \
 +      GIT_AUTHOR_EMAIL="nitfol@frobozz.com" \
 +      git commit -a -m "fourth"
  '
  
  test_expect_success 'log grep (1)' '
@@@ -377,28 -372,6 +377,28 @@@ test_expect_success 'log --grep --autho
        test_cmp expect actual
  '
  
 +test_expect_success 'log with multiple --author uses union' '
 +      git log --author="Thor" --author="Aster" --format=%s >actual &&
 +      {
 +          echo third && echo second && echo initial
 +      } >expect &&
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'log with --grep and multiple --author uses all-match' '
 +      git log --author="Thor" --author="Night" --grep=i --format=%s >actual &&
 +      {
 +          echo third && echo initial
 +      } >expect &&
 +      test_cmp expect actual
 +'
 +
 +test_expect_success 'log with --grep and multiple --author uses all-match' '
 +      git log --author="Thor" --author="Night" --grep=q --format=%s >actual &&
 +      >expect &&
 +      test_cmp expect actual
 +'
 +
  test_expect_success 'grep with CE_VALID file' '
        git update-index --assume-unchanged t/t &&
        rm t/t &&
@@@ -479,7 -452,7 +479,7 @@@ test_expect_success 'outside of git rep
                echo file1:hello &&
                echo sub/file2:world
        } >non/expect.full &&
-       echo file2:world >non/expect.sub
+       echo file2:world >non/expect.sub &&
        (
                GIT_CEILING_DIRECTORIES="$(pwd)/non/git" &&
                export GIT_CEILING_DIRECTORIES &&
@@@ -505,7 -478,7 +505,7 @@@ test_expect_success 'inside git reposit
                echo sub/file2:world
        } >is/expect.full &&
        : >is/expect.empty &&
-       echo file2:world >is/expect.sub
+       echo file2:world >is/expect.sub &&
        (
                cd is/git &&
                git init &&
diff --combined t/t9300-fast-import.sh
index 3c0cf0509d2cfe3afc0316ed50ea85cb0d2d14de,ab48f42d4b4b93fbf7d2c73ac03bcb1b9e243066..14d17691b1c48e2b3211812a16d6dda7e83ad31a
@@@ -321,7 -321,7 +321,7 @@@ test_expect_success 
        'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
  test_expect_success \
        'C: validate reuse existing blob' \
-       'test $newf = `git rev-parse --verify branch:file2/newf`
+       'test $newf = `git rev-parse --verify branch:file2/newf` &&
         test $oldf = `git rev-parse --verify branch:file2/oldf`'
  
  cat >expect <<EOF
@@@ -874,27 -874,6 +874,27 @@@ test_expect_success 
         git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
         compare_diff_raw expect actual'
  
 +test_expect_success \
 +      'N: copy root directory by tree hash' \
 +      'cat >expect <<-\EOF &&
 +      :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D      file3/newf
 +      :100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D      file3/oldf
 +      EOF
 +       root=$(git rev-parse refs/heads/branch^0^{tree}) &&
 +       cat >input <<-INPUT_END &&
 +      commit refs/heads/N6
 +      committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
 +      data <<COMMIT
 +      copy root directory by tree hash
 +      COMMIT
 +
 +      from refs/heads/branch^0
 +      M 040000 $root ""
 +      INPUT_END
 +       git fast-import <input &&
 +       git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
 +       compare_diff_raw expect actual'
 +
  test_expect_success \
        'N: modify copied tree' \
        'cat >expect <<-\EOF &&
diff --combined t/test-lib.sh
index 38e5a59ff7877b3d2624574ecb9584803fe46152,a417bdfed14bd56751aa4fd5787803b9eae9c25c..48fa5160045d0bb2c14d034422b2ee5170889ec5
@@@ -238,51 -238,14 +238,51 @@@ test_set_editor () 
  }
  
  test_decode_color () {
 -      sed     -e 's/.\[1m/<WHITE>/g' \
 -              -e 's/.\[31m/<RED>/g' \
 -              -e 's/.\[32m/<GREEN>/g' \
 -              -e 's/.\[33m/<YELLOW>/g' \
 -              -e 's/.\[34m/<BLUE>/g' \
 -              -e 's/.\[35m/<MAGENTA>/g' \
 -              -e 's/.\[36m/<CYAN>/g' \
 -              -e 's/.\[m/<RESET>/g'
 +      awk '
 +              function name(n) {
 +                      if (n == 0) return "RESET";
 +                      if (n == 1) return "BOLD";
 +                      if (n == 30) return "BLACK";
 +                      if (n == 31) return "RED";
 +                      if (n == 32) return "GREEN";
 +                      if (n == 33) return "YELLOW";
 +                      if (n == 34) return "BLUE";
 +                      if (n == 35) return "MAGENTA";
 +                      if (n == 36) return "CYAN";
 +                      if (n == 37) return "WHITE";
 +                      if (n == 40) return "BLACK";
 +                      if (n == 41) return "BRED";
 +                      if (n == 42) return "BGREEN";
 +                      if (n == 43) return "BYELLOW";
 +                      if (n == 44) return "BBLUE";
 +                      if (n == 45) return "BMAGENTA";
 +                      if (n == 46) return "BCYAN";
 +                      if (n == 47) return "BWHITE";
 +              }
 +              {
 +                      while (match($0, /\x1b\[[0-9;]*m/) != 0) {
 +                              printf "%s<", substr($0, 1, RSTART-1);
 +                              codes = substr($0, RSTART+2, RLENGTH-3);
 +                              if (length(codes) == 0)
 +                                      printf "%s", name(0)
 +                              else {
 +                                      n = split(codes, ary, ";");
 +                                      sep = "";
 +                                      for (i = 1; i <= n; i++) {
 +                                              printf "%s%s", sep, name(ary[i]);
 +                                              sep = ";"
 +                                      }
 +                              }
 +                              printf ">";
 +                              $0 = substr($0, RSTART + RLENGTH, length($0) - RSTART - RLENGTH + 1);
 +                      }
 +                      print
 +              }
 +      '
 +}
 +
 +nul_to_q () {
 +      perl -pe 'y/\000/Q/'
  }
  
  q_to_nul () {
@@@ -305,6 -268,17 +305,17 @@@ remove_cr () 
        tr '\015' Q | sed -e 's/Q$//'
  }
  
+ # In some bourne shell implementations, the "unset" builtin returns
+ # nonzero status when a variable to be unset was not set in the first
+ # place.
+ #
+ # Use sane_unset when that should not be considered an error.
+ sane_unset () {
+       unset "$@"
+       return 0
+ }
  test_tick () {
        if test -z "${test_tick+set}"
        then
@@@ -399,15 -373,6 +410,15 @@@ test_have_prereq () 
        test $total_prereq = $ok_prereq
  }
  
 +test_declared_prereq () {
 +      case ",$test_prereq," in
 +      *,$1,*)
 +              return 0
 +              ;;
 +      esac
 +      return 1
 +}
 +
  # You are not expected to call test_ok_ and test_failure_ directly, use
  # the text_expect_* functions instead.
  
@@@ -460,17 -425,17 +471,17 @@@ test_skip () 
                        break
                esac
        done
 -      if test -z "$to_skip" && test -n "$prereq" &&
 -         ! test_have_prereq "$prereq"
 +      if test -z "$to_skip" && test -n "$test_prereq" &&
 +         ! test_have_prereq "$test_prereq"
        then
                to_skip=t
        fi
        case "$to_skip" in
        t)
                of_prereq=
 -              if test "$missing_prereq" != "$prereq"
 +              if test "$missing_prereq" != "$test_prereq"
                then
 -                      of_prereq=" of $prereq"
 +                      of_prereq=" of $test_prereq"
                fi
  
                say_color skip >&3 "skipping test: $@"
  }
  
  test_expect_failure () {
 -      test "$#" = 3 && { prereq=$1; shift; } || prereq=
 +      test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
        test "$#" = 2 ||
        error "bug in the test script: not 2 or 3 parameters to test-expect-failure"
 +      export test_prereq
        if ! test_skip "$@"
        then
                say >&3 "checking known breakage: $2"
  }
  
  test_expect_success () {
 -      test "$#" = 3 && { prereq=$1; shift; } || prereq=
 +      test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq=
        test "$#" = 2 ||
        error "bug in the test script: not 2 or 3 parameters to test-expect-success"
 +      export test_prereq
        if ! test_skip "$@"
        then
                say >&3 "expecting success: $2"
        echo >&3 ""
  }
  
- test_expect_code () {
-       test "$#" = 4 && { prereq=$1; shift; } || prereq=
-       test "$#" = 3 ||
-       error "bug in the test script: not 3 or 4 parameters to test-expect-code"
-       if ! test_skip "$@"
-       then
-               say >&3 "expecting exit code $1: $3"
-               test_run_ "$3"
-               if [ "$?" = 0 -a "$eval_ret" = "$1" ]
-               then
-                       test_ok_ "$2"
-               else
-                       test_failure_ "$@"
-               fi
-       fi
-       echo >&3 ""
- }
  # test_external runs external test scripts that provide continuous
  # test output about their progress, and succeeds/fails on
  # zero/non-zero exit code.  It outputs the test output on stdout even
  # Usage: test_external description command arguments...
  # Example: test_external 'Perl API' perl ../path/to/test.pl
  test_external () {
 -      test "$#" = 4 && { prereq=$1; shift; } || prereq=
 +      test "$#" = 4 && { test_prereq=$1; shift; } || test_prereq=
        test "$#" = 3 ||
        error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
        descr="$1"
        shift
 +      export test_prereq
        if ! test_skip "$descr" "$@"
        then
                # Announce the script to reduce confusion about the
@@@ -654,6 -598,28 +647,28 @@@ test_path_is_missing () 
        fi
  }
  
+ # test_line_count checks that a file has the number of lines it
+ # ought to. For example:
+ #
+ #     test_expect_success 'produce exactly one line of output' '
+ #             do something >output &&
+ #             test_line_count = 1 output
+ #     '
+ #
+ # is like "test $(wc -l <output) = 1" except that it passes the
+ # output through when the number of lines is wrong.
+ test_line_count () {
+       if test $# != 3
+       then
+               error "bug in the test script: not 3 parameters to test_line_count"
+       elif ! test $(wc -l <"$3") "$1" "$2"
+       then
+               echo "test_line_count: line count for $3 !$1 $2"
+               cat "$3"
+               return 1
+       fi
+ }
  
  # This is not among top-level (test_expect_success | test_expect_failure)
  # but is a prefix that can be used in the test script, like:
@@@ -707,6 -673,28 +722,28 @@@ test_might_fail () 
        return 0
  }
  
+ # Similar to test_must_fail and test_might_fail, but check that a
+ # given command exited with a given exit code. Meant to be used as:
+ #
+ #     test_expect_success 'Merge with d/f conflicts' '
+ #             test_expect_code 1 git merge "merge msg" B master
+ #     '
+ test_expect_code () {
+       want_code=$1
+       shift
+       "$@"
+       exit_code=$?
+       if test $exit_code = $want_code
+       then
+               echo >&2 "test_expect_code: command exited with $exit_code: $*"
+               return 0
+       else
+               echo >&2 "test_expect_code: command exited with $exit_code, we wanted $want_code $*"
+               return 1
+       fi
+ }
  # test_cmp is a helper function to compare actual and expected output.
  # You can use it like:
  #
@@@ -1019,13 -1007,11 +1056,13 @@@ case $(uname -s) i
        # no POSIX permissions
        # backslashes in pathspec are converted to '/'
        # exec does not inherit the PID
 +      test_set_prereq MINGW
        ;;
  *)
        test_set_prereq POSIXPERM
        test_set_prereq BSLASHPSPEC
        test_set_prereq EXECKEEPSPID
 +      test_set_prereq NOT_MINGW
        ;;
  esac