2 # Copyright (c) 2006, Junio C Hamano.
4 test_description
='Per branch config variables affects "git fetch".
12 test_expect_success setup
'
13 echo >file original &&
15 git commit -a -m original'
17 test_expect_success
"clone and setup child repos" '
20 echo >file updated by one &&
21 git commit -a -m "updated by one" &&
25 git config branch.master.remote one &&
26 git config remote.one.url ../one/.git/ &&
27 git config remote.one.fetch refs/heads/master:refs/heads/one &&
31 git config branch.master.remote two &&
32 git config branch.master.merge refs/heads/one &&
33 mkdir -p .git/remotes &&
35 echo "URL: ../two/.git/"
36 echo "Pull: refs/heads/master:refs/heads/two"
37 echo "Pull: refs/heads/one:refs/heads/one"
38 } >.git/remotes/two &&
43 test_expect_success
"fetch test" '
45 echo >file updated by origin &&
46 git commit -a -m "updated by origin" &&
49 test -f .git/refs/heads/one &&
50 mine=`git rev-parse refs/heads/one` &&
51 his=`cd ../one && git rev-parse refs/heads/master` &&
52 test "z$mine" = "z$his"
55 test_expect_success
"fetch test for-merge" '
59 test -f .git/refs/heads/two &&
60 test -f .git/refs/heads/one &&
61 master_in_two=`cd ../two && git rev-parse master` &&
62 one_in_two=`cd ../two && git rev-parse one` &&
64 echo "$master_in_two not-for-merge"
67 cut -f -2 .git/FETCH_HEAD >actual &&
70 test_expect_success
'fetch tags when there is no tags' '
82 test_expect_success
'fetch following tags' '
85 git tag -a -m 'annotated
' anno HEAD &&
92 git fetch .. :track &&
93 git show-ref --verify refs/tags/anno &&
94 git show-ref --verify refs/tags/light
98 test_expect_failure
'fetch must not resolve short tag name' '
106 git fetch .. anno:five
110 test_expect_failure
'fetch must not resolve short remote name' '
113 git-update-ref refs/remotes/six/HEAD HEAD
123 test_expect_success
'create bundle 1' '
125 echo >file updated again by origin &&
126 git commit -a -m "tip" &&
127 git bundle create bundle1 master^..master
130 test_expect_success
'header of bundle looks right' '
131 head -n 1 "$D"/bundle1 | grep "^#" &&
132 head -n 2 "$D"/bundle1 | grep "^-[0-9a-f]\{40\} " &&
133 head -n 3 "$D"/bundle1 | grep "^[0-9a-f]\{40\} " &&
134 head -n 4 "$D"/bundle1 | grep "^$"
137 test_expect_success
'create bundle 2' '
139 git bundle create bundle2 master~2..master
142 test_expect_failure
'unbundle 1' '
144 git checkout -b some-branch &&
145 git fetch "$D/bundle1" master:master
148 test_expect_success
'bundle 1 has only 3 files ' '
151 while read x && test -n "$x"
156 ) <bundle1 >bundle.pack &&
157 git index-pack bundle.pack &&
158 verify=$(git verify-pack -v bundle.pack) &&
159 test 4 = $(echo "$verify" | wc -l)
162 test_expect_success
'unbundle 2' '
164 git fetch ../bundle2 master:master &&
165 test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)"
168 test_expect_success
'bundle does not prerequisite objects' '
172 git commit -m add.file2 file2 &&
173 git bundle create bundle3 -1 HEAD &&
175 while read x && test -n "$x"
180 ) <bundle3 >bundle.pack &&
181 git index-pack bundle.pack &&
182 test 4 = $(git verify-pack -v bundle.pack | wc -l)
185 test_expect_success
'bundle should be able to create a full history' '
188 git tag -a -m '1.0' v1.0 master &&
189 git bundle create bundle4 v1.0
193 test "$TEST_RSYNC" && {
194 test_expect_success
'fetch via rsync' '
199 git fetch rsync://127.0.0.1$(pwd)/../.git master:refs/heads/master &&
201 test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
205 test_expect_success
'push via rsync' '
209 git push rsync://127.0.0.1$(pwd)/../rsynced2/.git master &&
212 test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
216 test_expect_success
'push via rsync' '
221 git push --all rsync://127.0.0.1$(pwd)/rsynced3/.git &&
223 test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
228 test_expect_success
'fetch with a non-applying branch.<name>.merge' '
229 git config branch.master.remote yeti &&
230 git config branch.master.merge refs/heads/bigfoot &&
231 git config remote.blub.url one &&
232 git config remote.blub.fetch "refs/heads/*:refs/remotes/one/*" &&
236 # the strange name is: a\!'b
237 test_expect_success
'quoting of a strangely named repo' '
238 ! git fetch "a\\!'\''b" > result 2>&1 &&
240 grep "fatal: '\''a\\\\!'\''b'\''" result