1#!/bin/sh
2
3test_description='fetching and pushing, with or without wildcard'
4
5. ./test-lib.sh
6
7D=`pwd`
8
9mk_empty () {
10 rm -fr testrepo &&
11 mkdir testrepo &&
12 (
13 cd testrepo &&
14 git init
15 )
16}
17
18test_expect_success setup '
19
20 : >path1 &&
21 git add path1 &&
22 test_tick &&
23 git commit -a -m repo &&
24 the_commit=$(git show-ref -s --verify refs/heads/master)
25
26'
27
28test_expect_success 'fetch without wildcard' '
29 mk_empty &&
30 (
31 cd testrepo &&
32 git fetch .. refs/heads/master:refs/remotes/origin/master &&
33
34 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
35 test "z$r" = "z$the_commit" &&
36
37 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
38 )
39'
40
41test_expect_success 'fetch with wildcard' '
42 mk_empty &&
43 (
44 cd testrepo &&
45 git config remote.up.url .. &&
46 git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" &&
47 git fetch up &&
48
49 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
50 test "z$r" = "z$the_commit" &&
51
52 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
53 )
54'
55
56test_expect_success 'push without wildcard' '
57 mk_empty &&
58
59 git push testrepo refs/heads/master:refs/remotes/origin/master &&
60 (
61 cd testrepo &&
62 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
63 test "z$r" = "z$the_commit" &&
64
65 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
66 )
67'
68
69test_expect_success 'push with wildcard' '
70 mk_empty &&
71
72 git push testrepo "refs/heads/*:refs/remotes/origin/*" &&
73 (
74 cd testrepo &&
75 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
76 test "z$r" = "z$the_commit" &&
77
78 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
79 )
80'
81
82test_done