Code

Test wildcard push/fetch
[git.git] / t / t5516-fetch-push.sh
1 #!/bin/sh
3 test_description='fetching and pushing, with or without wildcard'
5 . ./test-lib.sh
7 D=`pwd`
9 mk_empty () {
10         rm -fr testrepo &&
11         mkdir testrepo &&
12         (
13                 cd testrepo &&
14                 git init
15         )
16 }
18 test_expect_success setup '
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)
26 '
28 test_expect_success 'fetch without wildcard' '
29         mk_empty &&
30         (
31                 cd testrepo &&
32                 git fetch .. refs/heads/master:refs/remotes/origin/master &&
34                 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
35                 test "z$r" = "z$the_commit" &&
37                 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
38         )
39 '
41 test_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 &&
49                 r=$(git show-ref -s --verify refs/remotes/origin/master) &&
50                 test "z$r" = "z$the_commit" &&
52                 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
53         )
54 '
56 test_expect_success 'push without wildcard' '
57         mk_empty &&
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" &&
65                 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
66         )
67 '
69 test_expect_success 'push with wildcard' '
70         mk_empty &&
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" &&
78                 test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
79         )
80 '
82 test_done