]>
Commit | Line | Data |
---|---|---|
ac3ec0d5 SB |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Santi Béjar, based on t4013 by Junio C Hamano | |
4 | # | |
5 | # | |
6 | ||
7 | test_description='Merge logic in fetch' | |
8 | ||
d790ee17 JT |
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= | |
12 | ||
ac3ec0d5 SB |
13 | . ./test-lib.sh |
14 | ||
ac3ec0d5 SB |
15 | test_expect_success setup ' |
16 | GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" && | |
17 | GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" && | |
18 | export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && | |
19 | ||
20 | echo >file original && | |
21 | git add file && | |
22 | git commit -a -m One && | |
23 | git tag tag-one && | |
24 | git tag tag-one-tree HEAD^{tree} && | |
25 | git branch one && | |
26 | ||
27 | echo two >> file && | |
28 | git commit -a -m Two && | |
29 | git tag -a -m "Tag Two" tag-two && | |
30 | git branch two && | |
31 | ||
32 | echo three >> file && | |
33 | git commit -a -m Three && | |
34 | git tag -a -m "Tag Three" tag-three && | |
35 | git tag -a -m "Tag Three file" tag-three-file HEAD^{tree}:file && | |
36 | git branch three && | |
37 | ||
38 | echo master >> file && | |
39 | git commit -a -m Master && | |
40 | git tag -a -m "Tag Master" tag-master && | |
41 | ||
42 | git checkout three && | |
43 | ||
44 | git clone . cloned && | |
45 | cd cloned && | |
46 | git config remote.origin.url ../.git/ && | |
47 | ||
48 | git config remote.config-explicit.url ../.git/ && | |
49 | git config remote.config-explicit.fetch refs/heads/master:remotes/rem/master && | |
50 | git config --add remote.config-explicit.fetch refs/heads/one:remotes/rem/one && | |
51 | git config --add remote.config-explicit.fetch two:remotes/rem/two && | |
52 | git config --add remote.config-explicit.fetch refs/heads/three:remotes/rem/three && | |
53 | remotes="config-explicit" && | |
54 | ||
55 | git config remote.config-glob.url ../.git/ && | |
56 | git config remote.config-glob.fetch refs/heads/*:refs/remotes/rem/* && | |
57 | remotes="$remotes config-glob" && | |
58 | ||
59 | mkdir -p .git/remotes && | |
60 | { | |
61 | echo "URL: ../.git/" | |
62 | echo "Pull: refs/heads/master:remotes/rem/master" | |
63 | echo "Pull: refs/heads/one:remotes/rem/one" | |
64 | echo "Pull: two:remotes/rem/two" | |
65 | echo "Pull: refs/heads/three:remotes/rem/three" | |
66 | } >.git/remotes/remote-explicit && | |
67 | remotes="$remotes remote-explicit" && | |
68 | ||
69 | { | |
70 | echo "URL: ../.git/" | |
71 | echo "Pull: refs/heads/*:refs/remotes/rem/*" | |
72 | } >.git/remotes/remote-glob && | |
73 | remotes="$remotes remote-glob" && | |
74 | ||
75 | mkdir -p .git/branches && | |
76 | echo "../.git" > .git/branches/branches-default && | |
77 | remotes="$remotes branches-default" && | |
78 | ||
79 | echo "../.git#one" > .git/branches/branches-one && | |
80 | remotes="$remotes branches-one" && | |
81 | ||
82 | for remote in $remotes ; do | |
83 | git config branch.br-$remote.remote $remote && | |
84 | git config branch.br-$remote-merge.remote $remote && | |
85 | git config branch.br-$remote-merge.merge refs/heads/three && | |
86 | git config branch.br-$remote-octopus.remote $remote && | |
87 | git config branch.br-$remote-octopus.merge refs/heads/one && | |
d8b3a2bf | 88 | git config --add branch.br-$remote-octopus.merge two |
ac3ec0d5 SB |
89 | done |
90 | ' | |
91 | ||
92 | # Merge logic depends on branch properties and Pull: or .fetch lines | |
93 | for remote in $remotes ; do | |
94 | for branch in "" "-merge" "-octopus" ; do | |
95 | cat <<EOF | |
96 | br-$remote$branch | |
97 | br-$remote$branch $remote | |
98 | EOF | |
99 | done | |
100 | done > tests | |
101 | ||
102 | # Merge logic does not depend on branch properties, | |
103 | # but does depend on Pull: or fetch lines. | |
104 | # Use two branches completely unrelated from the arguments, | |
105 | # the clone default and one without branch properties | |
106 | for branch in master br-unconfig ; do | |
107 | echo $branch | |
108 | for remote in $remotes ; do | |
109 | echo $branch $remote | |
110 | done | |
111 | done >> tests | |
112 | ||
113 | # Merge logic does not depend on branch properties | |
114 | # neither in the Pull: or .fetch config | |
115 | for branch in master br-unconfig ; do | |
116 | cat <<EOF | |
e3d842cf | 117 | $branch ../.git |
ac3ec0d5 SB |
118 | $branch ../.git one |
119 | $branch ../.git one two | |
120 | $branch --tags ../.git | |
121 | $branch ../.git tag tag-one tag tag-three | |
122 | $branch ../.git tag tag-one-tree tag tag-three-file | |
123 | $branch ../.git one tag tag-one tag tag-three-file | |
124 | EOF | |
125 | done >> tests | |
126 | ||
127 | while read cmd | |
128 | do | |
129 | case "$cmd" in | |
130 | '' | '#'*) continue ;; | |
131 | esac | |
28666e55 EP |
132 | test=$(echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g') |
133 | pfx=$(printf "%04d" $test_count) | |
bfdbee98 | 134 | expect_f="$TEST_DIRECTORY/t5515/fetch.$test" |
a466637c | 135 | actual_f="$pfx-fetch.$test" |
bfdbee98 | 136 | expect_r="$TEST_DIRECTORY/t5515/refs.$test" |
a466637c | 137 | actual_r="$pfx-refs.$test" |
ac3ec0d5 SB |
138 | |
139 | test_expect_success "$cmd" ' | |
140 | { | |
141 | echo "# $cmd" | |
142 | set x $cmd; shift | |
143 | git symbolic-ref HEAD refs/heads/$1 ; shift | |
144 | rm -f .git/FETCH_HEAD | |
d0d12b47 JH |
145 | git for-each-ref \ |
146 | refs/heads refs/remotes/rem refs/tags | | |
147 | while read val type refname | |
148 | do | |
149 | git update-ref -d "$refname" "$val" | |
150 | done | |
ac3ec0d5 SB |
151 | git fetch "$@" >/dev/null |
152 | cat .git/FETCH_HEAD | |
a466637c JH |
153 | } >"$actual_f" && |
154 | git show-ref >"$actual_r" && | |
155 | if test -f "$expect_f" | |
ac3ec0d5 | 156 | then |
3af82863 | 157 | test_cmp "$expect_f" "$actual_f" && |
a466637c | 158 | rm -f "$actual_f" |
ac3ec0d5 SB |
159 | else |
160 | # this is to help developing new tests. | |
a466637c JH |
161 | cp "$actual_f" "$expect_f" |
162 | false | |
163 | fi && | |
164 | if test -f "$expect_r" | |
165 | then | |
3af82863 | 166 | test_cmp "$expect_r" "$actual_r" && |
a466637c JH |
167 | rm -f "$actual_r" |
168 | else | |
169 | # this is to help developing new tests. | |
170 | cp "$actual_r" "$expect_r" | |
ac3ec0d5 SB |
171 | false |
172 | fi | |
173 | ' | |
174 | done < tests | |
175 | ||
176 | test_done |