Code

Merge branch 'js/diff-ni'
authorJunio C Hamano <junkio@cox.net>
Sun, 11 Mar 2007 07:26:33 +0000 (23:26 -0800)
committerJunio C Hamano <junkio@cox.net>
Sun, 11 Mar 2007 07:26:33 +0000 (23:26 -0800)
* js/diff-ni:
  Get rid of the dependency to GNU diff in the tests
  diff --no-index: support /dev/null as filename
  diff-ni: fix the diff with standard input
  diff: support reading a file from stdin via "-"

1  2 
diff-lib.c
diff.c
t/t1300-repo-config.sh
t/t5400-send-pack.sh
t/t5401-update-hooks.sh
t/t5515-fetch-merge-logic.sh
t/t9300-fast-import.sh

diff --cc diff-lib.c
Simple merge
diff --cc diff.c
Simple merge
index ee386cfbf3be4d457644103b223e1fcafaa363ba,84a59397b2427615165a243f2fd53e81ee8f8ce9..78c2e0864f56ecf39e8738e8fecec9ca8dd4e8a2
@@@ -389,24 -389,8 +389,24 @@@ cat > expect << EO
  weird
  EOF
  
- test_expect_success "rename succeeded" "diff -u expect .git/config"
+ test_expect_success "rename succeeded" "git diff expect .git/config"
  
-       "diff -u expect .git/config"
 +cat >> .git/config << EOF
 +  [branch "zwei"] a = 1 [branch "vier"]
 +EOF
 +
 +test_expect_success "remove section" "git config --remove-section branch.zwei"
 +
 +cat > expect << EOF
 +# Hallo
 +      #Bello
 +[branch "drei"]
 +weird
 +EOF
 +
 +test_expect_success "section was removed properly" \
++      "git diff -u expect .git/config"
 +
  test_expect_success numbers '
  
        git-config kilo.gram 1k &&
index b1c97b0dfb1748a7ba80c18d2d4b84bdee192c95,fc4a126407fbfd9cf630d6fca03d7392342d3e15..477b267599512fee5a5a3cf86687c3708ff967b8
@@@ -108,9 -108,9 +108,9 @@@ test_expect_success 
        cd victim &&
        git-config receive.denyNonFastforwards true &&
        cd .. &&
 -      git-update-ref refs/heads/master master^ &&
 -      git-send-pack --force ./victim/.git/ master &&
 +      git-update-ref refs/heads/master master^ || return 1
 +      git-send-pack --force ./victim/.git/ master && return 1
-       ! diff .git/refs/heads/master victim/.git/refs/heads/master
+       ! git diff .git/refs/heads/master victim/.git/refs/heads/master
  '
  
  test_done
index 0c0034e34c616fc8a385956a21e282a98b480b37,460c9fd7fe1abb426a1fd977ff29214bde5bbe3e..cf6306ce9f4050e65f7e2cd69f5d5e68b04fb12d
@@@ -80,55 -49,33 +80,55 @@@ test_expect_success 'hooks ran' 
        test -f victim/.git/post-update.stdin
  '
  
-       | diff - victim/.git/pre-receive.args
 +test_expect_success 'pre-receive hook arguments' '
 +      echo \
 +       refs/heads/master $commit0 $commit1 \
 +       refs/heads/tofail $commit1 $commit0 \
++      | git diff - victim/.git/pre-receive.args
 +'
 +
  test_expect_success 'update hook arguments' '
-       ) | diff - victim/.git/update.args
 +      (echo refs/heads/master $commit0 $commit1;
 +       echo refs/heads/tofail $commit1 $commit0
++      ) | git diff - victim/.git/update.args
 +'
 +
 +test_expect_success 'post-receive hook arguments' '
        echo refs/heads/master $commit0 $commit1 |
-       diff - victim/.git/post-receive.args
 -      git diff - victim/.git/update.args
++      git diff - victim/.git/post-receive.args
  '
  
  test_expect_success 'post-update hook arguments' '
        echo refs/heads/master |
-       diff -u - victim/.git/post-update.args
+       git diff - victim/.git/post-update.args
  '
  
 -test_expect_failure 'update hook stdin is /dev/null' '
 -      test -s victim/.git/update.stdin
 -'
 -
 -test_expect_failure 'post-update hook stdin is /dev/null' '
 -      test -s victim/.git/post-update.stdin
 +test_expect_success 'all hook stdin is /dev/null' '
 +      ! test -s victim/.git/pre-receive.stdin &&
 +      ! test -s victim/.git/update.stdin &&
 +      ! test -s victim/.git/post-receive.stdin &&
 +      ! test -s victim/.git/post-update.stdin
  '
  
  test_expect_failure 'send-pack produced no output' '
        test -s send.out
  '
  
 +cat <<EOF >expect
 +STDOUT pre-receive
 +STDERR pre-receive
 +STDOUT update refs/heads/master
 +STDERR update refs/heads/master
 +STDOUT update refs/heads/tofail
 +STDERR update refs/heads/tofail
 +STDOUT post-receive
 +STDERR post-receive
 +STDOUT post-update
 +STDERR post-update
 +EOF
  test_expect_success 'send-pack stderr contains hook messages' '
 -      grep "STDOUT update" send.err &&
 -      grep "STDERR update" send.err &&
 -      grep "STDOUT post-update" send.err &&
 -      grep "STDERR post-update" send.err
 +      egrep ^STD send.err >actual &&
-       diff - actual <expect
++      git diff - actual <expect
  '
  
  test_done
index 0b600bb429b69df02d971913e4b658bf7e313277,0000000000000000000000000000000000000000..6c9cc67508f4351f5627b613215e6b88b0adc49a
mode 100755,000000..100755
--- /dev/null
@@@ -1,162 -1,0 +1,162 @@@
-                       diff -u "$expect" "$actual" &&
 +#!/bin/sh
 +#
 +# Copyright (c) 2007 Santi BĂ©jar, based on t4013 by Junio C Hamano
 +#
 +#
 +
 +test_description='Merge logic in fetch'
 +
 +. ./test-lib.sh
 +
 +LF='
 +'
 +
 +test_expect_success setup '
 +      GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
 +      GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
 +      export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
 +
 +      echo >file original &&
 +      git add file &&
 +      git commit -a -m One &&
 +      git tag tag-one &&
 +      git tag tag-one-tree HEAD^{tree} &&
 +      git branch one &&
 +
 +      echo two >> file &&
 +      git commit -a -m Two &&
 +      git tag -a -m "Tag Two" tag-two &&
 +      git branch two &&
 +
 +      echo three >> file &&
 +      git commit -a -m Three &&
 +      git tag -a -m "Tag Three" tag-three &&
 +      git tag -a -m "Tag Three file" tag-three-file HEAD^{tree}:file &&
 +      git branch three &&
 +
 +      echo master >> file &&
 +      git commit -a -m Master &&
 +      git tag -a -m "Tag Master" tag-master &&
 +
 +      git checkout three &&
 +
 +      git clone . cloned &&
 +      cd cloned &&
 +      git config remote.origin.url ../.git/ &&
 +
 +      git config remote.config-explicit.url ../.git/ &&
 +      git config remote.config-explicit.fetch refs/heads/master:remotes/rem/master &&
 +      git config --add remote.config-explicit.fetch refs/heads/one:remotes/rem/one &&
 +      git config --add remote.config-explicit.fetch two:remotes/rem/two &&
 +      git config --add remote.config-explicit.fetch refs/heads/three:remotes/rem/three &&
 +      remotes="config-explicit" &&
 +
 +      git config remote.config-glob.url ../.git/ &&
 +      git config remote.config-glob.fetch refs/heads/*:refs/remotes/rem/* &&
 +      remotes="$remotes config-glob" &&
 +
 +      mkdir -p .git/remotes &&
 +      {
 +              echo "URL: ../.git/"
 +              echo "Pull: refs/heads/master:remotes/rem/master"
 +              echo "Pull: refs/heads/one:remotes/rem/one"
 +              echo "Pull: two:remotes/rem/two"
 +              echo "Pull: refs/heads/three:remotes/rem/three"
 +      } >.git/remotes/remote-explicit &&
 +      remotes="$remotes remote-explicit" &&
 +
 +      {
 +              echo "URL: ../.git/"
 +              echo "Pull: refs/heads/*:refs/remotes/rem/*"
 +      } >.git/remotes/remote-glob &&
 +      remotes="$remotes remote-glob" &&
 +
 +      mkdir -p .git/branches &&
 +      echo "../.git" > .git/branches/branches-default &&
 +      remotes="$remotes branches-default" &&
 +
 +      echo "../.git#one" > .git/branches/branches-one &&
 +      remotes="$remotes branches-one" &&
 +
 +      for remote in $remotes ; do
 +              git config branch.br-$remote.remote $remote &&
 +              git config branch.br-$remote-merge.remote $remote &&
 +              git config branch.br-$remote-merge.merge refs/heads/three &&
 +              git config branch.br-$remote-octopus.remote $remote &&
 +              git config branch.br-$remote-octopus.merge refs/heads/one &&
 +              git config --add branch.br-$remote-octopus.merge two &&
 +              git config --add branch.br-$remote-octopus.merge remotes/rem/three
 +      done
 +'
 +
 +# Merge logic depends on branch properties and Pull: or .fetch lines
 +for remote in $remotes ; do
 +    for branch in "" "-merge" "-octopus" ; do
 +cat <<EOF
 +br-$remote$branch
 +br-$remote$branch $remote
 +EOF
 +    done
 +done > tests
 +
 +# Merge logic does not depend on branch properties,
 +# but does depend on Pull: or fetch lines.
 +# Use two branches completely unrelated from the arguments,
 +# the clone default and one without branch properties
 +for branch in master br-unconfig ; do
 +    echo $branch
 +    for remote in $remotes ; do
 +      echo $branch $remote
 +    done
 +done >> tests
 +
 +# Merge logic does not depend on branch properties
 +# neither in the Pull: or .fetch config
 +for branch in master br-unconfig ; do
 +    cat <<EOF
 +$branch ../.git
 +$branch ../.git one
 +$branch ../.git one two
 +$branch --tags ../.git
 +$branch ../.git tag tag-one tag tag-three
 +$branch ../.git tag tag-one-tree tag tag-three-file
 +$branch ../.git one tag tag-one tag tag-three-file
 +EOF
 +done >> tests
 +
 +while read cmd
 +do
 +      case "$cmd" in
 +      '' | '#'*) continue ;;
 +      esac
 +      test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
 +      cnt=`expr $test_count + 1`
 +      pfx=`printf "%04d" $cnt`
 +      expect="../../t5515/fetch.$test"
 +      actual="$pfx-fetch.$test"
 +
 +      test_expect_success "$cmd" '
 +              {
 +                      echo "# $cmd"
 +                      set x $cmd; shift
 +                      git symbolic-ref HEAD refs/heads/$1 ; shift
 +                      rm -f .git/FETCH_HEAD
 +                      rm -f .git/refs/heads/*
 +                      rm -f .git/refs/remotes/rem/*
 +                      rm -f .git/refs/tags/*
 +                      git fetch "$@" >/dev/null
 +                      cat .git/FETCH_HEAD
 +              } >"$actual" &&
 +              if test -f "$expect"
 +              then
++                      git diff -u "$expect" "$actual" &&
 +                      rm -f "$actual"
 +              else
 +                      # this is to help developing new tests.
 +                      cp "$actual" "$expect"
 +                      false
 +              fi
 +      '
 +done < tests
 +
 +test_done
index 2e1a09ff2db29421629b038a3374449c49bdc79d,2337d83d35115ece1dc18692de4281081a267f0d..03f2f8f347f388a381447e238051cbb92b990dd8
@@@ -109,16 -109,8 +109,16 @@@ cat >expect <<EO
  EOF
  test_expect_success \
        'A: verify marks output' \
-       'diff -u expect marks.out'
+       'git diff expect marks.out'
  
-       diff -u expect marks.new'
 +test_expect_success \
 +      'A: verify marks import' \
 +      'git-fast-import \
 +              --import-marks=marks.out \
 +              --export-marks=marks.new \
 +              </dev/null &&
++      git diff -u expect marks.new'
 +
  ###
  ### series B
  ###