I like the idea of the new ':/<oneline prefix>' notation, and gave it
[git/jrn.git] / t / t5510-fetch.sh
blobfa76662dce3dd45cf9d59f57a151c7ab209d4014
1 #!/bin/sh
2 # Copyright (c) 2006, Junio C Hamano.
4 test_description='Per branch config variables affects "git fetch".
8 . ./test-lib.sh
10 D=`pwd`
12 test_expect_success setup '
13 echo >file original &&
14 git add file &&
15 git commit -a -m original'
17 test_expect_success "clone and setup child repos" '
18 git clone . one &&
19 cd one &&
20 echo >file updated by one &&
21 git commit -a -m "updated by one" &&
22 cd .. &&
23 git clone . two &&
24 cd two &&
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 &&
28 cd .. &&
29 git clone . three &&
30 cd three &&
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 &&
39 cd .. &&
40 git clone . bundle
43 test_expect_success "fetch test" '
44 cd "$D" &&
45 echo >file updated by origin &&
46 git commit -a -m "updated by origin" &&
47 cd two &&
48 git fetch &&
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" '
56 cd "$D" &&
57 cd three &&
58 git fetch &&
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"
65 echo "$one_in_two "
66 } >expected &&
67 cut -f -2 .git/FETCH_HEAD >actual &&
68 diff expected actual'
70 test_expect_success 'fetch following tags' '
72 cd "$D" &&
73 git tag -a -m 'annotated' anno HEAD &&
74 git tag light HEAD &&
76 mkdir four &&
77 cd four &&
78 git init &&
80 git fetch .. :track &&
81 git show-ref --verify refs/tags/anno &&
82 git show-ref --verify refs/tags/light
86 test_expect_success 'create bundle 1' '
87 cd "$D" &&
88 echo >file updated again by origin &&
89 git commit -a -m "tip" &&
90 git bundle create bundle1 master^..master
93 test_expect_success 'create bundle 2' '
94 cd "$D" &&
95 git bundle create bundle2 master~2..master
98 test_expect_failure 'unbundle 1' '
99 cd "$D/bundle" &&
100 git checkout -b some-branch &&
101 git fetch "$D/bundle1" master:master
104 test_expect_success 'unbundle 2' '
105 cd "$D/bundle" &&
106 git fetch ../bundle2 master:master &&
107 test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)"
110 test_done