3 # Copyright (c) 2007 Santi BĂ©jar, based on t4013 by Junio C Hamano
 
   7 test_description='Merge logic in fetch'
 
   9 # NEEDSWORK: If the overspecification of the expected result is reduced, we
 
  10 # might be able to run this test in all protocol versions.
 
  11 GIT_TEST_PROTOCOL_VERSION=0
 
  12 export GIT_TEST_PROTOCOL_VERSION
 
  16 test_expect_success setup '
 
  17         GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
 
  18         GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
 
  19         export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
 
  21         echo >file original &&
 
  23         git commit -a -m One &&
 
  25         git tag tag-one-tree HEAD^{tree} &&
 
  29         git commit -a -m Two &&
 
  30         git tag -a -m "Tag Two" tag-two &&
 
  34         git commit -a -m Three &&
 
  35         git tag -a -m "Tag Three" tag-three &&
 
  36         git tag -a -m "Tag Three file" tag-three-file HEAD^{tree}:file &&
 
  39         echo master >> file &&
 
  40         git commit -a -m Master &&
 
  41         git tag -a -m "Tag Master" tag-master &&
 
  47         git config remote.origin.url ../.git/ &&
 
  49         git config remote.config-explicit.url ../.git/ &&
 
  50         git config remote.config-explicit.fetch refs/heads/master:remotes/rem/master &&
 
  51         git config --add remote.config-explicit.fetch refs/heads/one:remotes/rem/one &&
 
  52         git config --add remote.config-explicit.fetch two:remotes/rem/two &&
 
  53         git config --add remote.config-explicit.fetch refs/heads/three:remotes/rem/three &&
 
  54         remotes="config-explicit" &&
 
  56         git config remote.config-glob.url ../.git/ &&
 
  57         git config remote.config-glob.fetch refs/heads/*:refs/remotes/rem/* &&
 
  58         remotes="$remotes config-glob" &&
 
  60         mkdir -p .git/remotes &&
 
  63                 echo "Pull: refs/heads/master:remotes/rem/master"
 
  64                 echo "Pull: refs/heads/one:remotes/rem/one"
 
  65                 echo "Pull: two:remotes/rem/two"
 
  66                 echo "Pull: refs/heads/three:remotes/rem/three"
 
  67         } >.git/remotes/remote-explicit &&
 
  68         remotes="$remotes remote-explicit" &&
 
  72                 echo "Pull: refs/heads/*:refs/remotes/rem/*"
 
  73         } >.git/remotes/remote-glob &&
 
  74         remotes="$remotes remote-glob" &&
 
  76         mkdir -p .git/branches &&
 
  77         echo "../.git" > .git/branches/branches-default &&
 
  78         remotes="$remotes branches-default" &&
 
  80         echo "../.git#one" > .git/branches/branches-one &&
 
  81         remotes="$remotes branches-one" &&
 
  83         for remote in $remotes ; do
 
  84                 git config branch.br-$remote.remote $remote &&
 
  85                 git config branch.br-$remote-merge.remote $remote &&
 
  86                 git config branch.br-$remote-merge.merge refs/heads/three &&
 
  87                 git config branch.br-$remote-octopus.remote $remote &&
 
  88                 git config branch.br-$remote-octopus.merge refs/heads/one &&
 
  89                 git config --add branch.br-$remote-octopus.merge two
 
  93 # Merge logic depends on branch properties and Pull: or .fetch lines
 
  94 for remote in $remotes ; do
 
  95     for branch in "" "-merge" "-octopus" ; do
 
  98 br-$remote$branch $remote
 
 103 # Merge logic does not depend on branch properties,
 
 104 # but does depend on Pull: or fetch lines.
 
 105 # Use two branches completely unrelated from the arguments,
 
 106 # the clone default and one without branch properties
 
 107 for branch in master br-unconfig ; do
 
 109     for remote in $remotes ; do
 
 114 # Merge logic does not depend on branch properties
 
 115 # neither in the Pull: or .fetch config
 
 116 for branch in master br-unconfig ; do
 
 120 $branch ../.git one two
 
 121 $branch --tags ../.git
 
 122 $branch ../.git tag tag-one tag tag-three
 
 123 $branch ../.git tag tag-one-tree tag tag-three-file
 
 124 $branch ../.git one tag tag-one tag tag-three-file
 
 131         '' | '#'*) continue ;;
 
 133         test=$(echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g')
 
 134         pfx=$(printf "%04d" $test_count)
 
 135         expect_f="$TEST_DIRECTORY/t5515/fetch.$test"
 
 136         actual_f="$pfx-fetch.$test"
 
 137         expect_r="$TEST_DIRECTORY/t5515/refs.$test"
 
 138         actual_r="$pfx-refs.$test"
 
 140         test_expect_success "$cmd" '
 
 144                         git symbolic-ref HEAD refs/heads/$1 ; shift
 
 145                         rm -f .git/FETCH_HEAD
 
 147                                 refs/heads refs/remotes/rem refs/tags |
 
 148                         while read val type refname
 
 150                                 git update-ref -d "$refname" "$val"
 
 152                         git fetch "$@" >/dev/null
 
 155                 git show-ref >"$actual_r" &&
 
 156                 if test -f "$expect_f"
 
 158                         test_cmp "$expect_f" "$actual_f" &&
 
 161                         # this is to help developing new tests.
 
 162                         cp "$actual_f" "$expect_f"
 
 165                 if test -f "$expect_r"
 
 167                         test_cmp "$expect_r" "$actual_r" &&
 
 170                         # this is to help developing new tests.
 
 171                         cp "$actual_r" "$expect_r"