submodule: Use cat instead of echo to avoid DOS line-endings
[git/dscho.git] / t / t5509-fetch-push-namespaces.sh
blobcc0b31f6b085dab117aff0b6d65841bcf656f265
1 #!/bin/sh
3 test_description='fetch/push involving ref namespaces'
4 . ./test-lib.sh
6 test_expect_success setup '
7 test_tick &&
8 git init original &&
10 cd original &&
11 echo 0 >count &&
12 git add count &&
13 test_commit 0 &&
14 echo 1 >count &&
15 git add count &&
16 test_commit 1 &&
17 git remote add pushee-namespaced "ext::git --namespace=namespace %s ../pushee" &&
18 git remote add pushee-unnamespaced ../pushee
19 ) &&
20 commit0=$(cd original && git rev-parse HEAD^) &&
21 commit1=$(cd original && git rev-parse HEAD) &&
22 git init pushee &&
23 git init puller
26 test_expect_success 'pushing into a repository using a ref namespace' '
28 cd original &&
29 git push pushee-namespaced master &&
30 git ls-remote pushee-namespaced >actual &&
31 printf "$commit1\trefs/heads/master\n" >expected &&
32 test_cmp expected actual &&
33 git push pushee-namespaced --tags &&
34 git ls-remote pushee-namespaced >actual &&
35 printf "$commit0\trefs/tags/0\n" >>expected &&
36 printf "$commit1\trefs/tags/1\n" >>expected &&
37 test_cmp expected actual &&
38 # Verify that the GIT_NAMESPACE environment variable works as well
39 GIT_NAMESPACE=namespace git ls-remote "ext::git %s ../pushee" >actual &&
40 test_cmp expected actual &&
41 # Verify that --namespace overrides GIT_NAMESPACE
42 GIT_NAMESPACE=garbage git ls-remote pushee-namespaced >actual &&
43 test_cmp expected actual &&
44 # Try a namespace with no content
45 git ls-remote "ext::git --namespace=garbage %s ../pushee" >actual &&
46 test_cmp /dev/null actual &&
47 git ls-remote pushee-unnamespaced >actual &&
48 sed -e "s|refs/|refs/namespaces/namespace/refs/|" expected >expected.unnamespaced &&
49 test_cmp expected.unnamespaced actual
53 test_expect_success 'pulling from a repository using a ref namespace' '
55 cd puller &&
56 git remote add -f pushee-namespaced "ext::git --namespace=namespace %s ../pushee" &&
57 git for-each-ref refs/ >actual &&
58 printf "$commit1 commit\trefs/remotes/pushee-namespaced/master\n" >expected &&
59 printf "$commit0 commit\trefs/tags/0\n" >>expected &&
60 printf "$commit1 commit\trefs/tags/1\n" >>expected &&
61 test_cmp expected actual
65 # This test with clone --mirror checks for possible regressions in clone
66 # or the machinery underneath it. It ensures that no future change
67 # causes clone to ignore refs in refs/namespaces/*. In particular, it
68 # protects against a regression caused by any future change to the refs
69 # machinery that might cause it to ignore refs outside of refs/heads/*
70 # or refs/tags/*. More generally, this test also checks the high-level
71 # functionality of using clone --mirror to back up a set of repos hosted
72 # in the namespaces of a single repo.
73 test_expect_success 'mirroring a repository using a ref namespace' '
74 git clone --mirror pushee mirror &&
76 cd mirror &&
77 git for-each-ref refs/ >actual &&
78 printf "$commit1 commit\trefs/namespaces/namespace/refs/heads/master\n" >expected &&
79 printf "$commit0 commit\trefs/namespaces/namespace/refs/tags/0\n" >>expected &&
80 printf "$commit1 commit\trefs/namespaces/namespace/refs/tags/1\n" >>expected &&
81 test_cmp expected actual
85 test_done