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
=
18 test_expect_success setup
'
19 GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
20 GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
21 export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
23 echo >file original &&
25 git commit -a -m One &&
27 git tag tag-one-tree HEAD^{tree} &&
31 git commit -a -m Two &&
32 git tag -a -m "Tag Two" tag-two &&
36 git commit -a -m Three &&
37 git tag -a -m "Tag Three" tag-three &&
38 git tag -a -m "Tag Three file" tag-three-file HEAD^{tree}:file &&
41 echo master >> file &&
42 git commit -a -m Master &&
43 git tag -a -m "Tag Master" tag-master &&
49 git config remote.origin.url ../.git/ &&
51 git config remote.config-explicit.url ../.git/ &&
52 git config remote.config-explicit.fetch refs/heads/master:remotes/rem/master &&
53 git config --add remote.config-explicit.fetch refs/heads/one:remotes/rem/one &&
54 git config --add remote.config-explicit.fetch two:remotes/rem/two &&
55 git config --add remote.config-explicit.fetch refs/heads/three:remotes/rem/three &&
56 remotes="config-explicit" &&
58 git config remote.config-glob.url ../.git/ &&
59 git config remote.config-glob.fetch refs/heads/*:refs/remotes/rem/* &&
60 remotes="$remotes config-glob" &&
62 mkdir -p .git/remotes &&
65 echo "Pull: refs/heads/master:remotes/rem/master"
66 echo "Pull: refs/heads/one:remotes/rem/one"
67 echo "Pull: two:remotes/rem/two"
68 echo "Pull: refs/heads/three:remotes/rem/three"
69 } >.git/remotes/remote-explicit &&
70 remotes="$remotes remote-explicit" &&
74 echo "Pull: refs/heads/*:refs/remotes/rem/*"
75 } >.git/remotes/remote-glob &&
76 remotes="$remotes remote-glob" &&
78 mkdir -p .git/branches &&
79 echo "../.git" > .git/branches/branches-default &&
80 remotes="$remotes branches-default" &&
82 echo "../.git#one" > .git/branches/branches-one &&
83 remotes="$remotes branches-one" &&
85 for remote in $remotes ; do
86 git config branch.br-$remote.remote $remote &&
87 git config branch.br-$remote-merge.remote $remote &&
88 git config branch.br-$remote-merge.merge refs/heads/three &&
89 git config branch.br-$remote-octopus.remote $remote &&
90 git config branch.br-$remote-octopus.merge refs/heads/one &&
91 git config --add branch.br-$remote-octopus.merge two
95 # Merge logic depends on branch properties and Pull: or .fetch lines
96 for remote
in $remotes ; do
97 for branch
in "" "-merge" "-octopus" ; do
100 br-$remote$branch $remote
105 # Merge logic does not depend on branch properties,
106 # but does depend on Pull: or fetch lines.
107 # Use two branches completely unrelated from the arguments,
108 # the clone default and one without branch properties
109 for branch
in master br-unconfig
; do
111 for remote
in $remotes ; do
116 # Merge logic does not depend on branch properties
117 # neither in the Pull: or .fetch config
118 for branch
in master br-unconfig
; do
122 $branch ../.git one two
123 $branch --tags ../.git
124 $branch ../.git tag tag-one tag tag-three
125 $branch ../.git tag tag-one-tree tag tag-three-file
126 $branch ../.git one tag tag-one tag tag-three-file
133 '' |
'#'*) continue ;;
135 test=$
(echo "$cmd" |
sed -e 's|[/ ][/ ]*|_|g')
136 pfx
=$
(printf "%04d" $test_count)
137 expect_f
="$TEST_DIRECTORY/t5515/fetch.$test"
138 actual_f
="$pfx-fetch.$test"
139 expect_r
="$TEST_DIRECTORY/t5515/refs.$test"
140 actual_r
="$pfx-refs.$test"
142 test_expect_success
"$cmd" '
146 git symbolic-ref HEAD refs/heads/$1 ; shift
147 rm -f .git/FETCH_HEAD
149 refs/heads refs/remotes/rem refs/tags |
150 while read val type refname
152 git update-ref -d "$refname" "$val"
154 git fetch "$@" >/dev/null
157 git show-ref >"$actual_r" &&
158 if test -f "$expect_f"
160 test_cmp "$expect_f" "$actual_f" &&
163 # this is to help developing new tests.
164 cp "$actual_f" "$expect_f"
167 if test -f "$expect_r"
169 test_cmp "$expect_r" "$actual_r" &&
172 # this is to help developing new tests.
173 cp "$actual_r" "$expect_r"