t/helper: merge test-ref-store into test-tool
[alt-git.git] / t / t5538-push-shallow.sh
blobecbf84d21c807a8d211c2068bd0a5d10deae4758
1 #!/bin/sh
3 test_description='push from/to a shallow clone'
5 . ./test-lib.sh
7 commit() {
8 echo "$1" >tracked &&
9 git add tracked &&
10 git commit -m "$1"
13 test_expect_success 'setup' '
14 git config --global transfer.fsckObjects true &&
15 commit 1 &&
16 commit 2 &&
17 commit 3 &&
18 commit 4 &&
19 git clone . full &&
21 git init full-abc &&
22 cd full-abc &&
23 commit a &&
24 commit b &&
25 commit c
26 ) &&
27 git clone --no-local --depth=2 .git shallow &&
28 git --git-dir=shallow/.git log --format=%s >actual &&
29 cat <<EOF >expect &&
32 EOF
33 test_cmp expect actual &&
34 git clone --no-local --depth=2 full-abc/.git shallow2 &&
35 git --git-dir=shallow2/.git log --format=%s >actual &&
36 cat <<EOF >expect &&
39 EOF
40 test_cmp expect actual
43 test_expect_success 'push from shallow clone' '
45 cd shallow &&
46 commit 5 &&
47 git push ../.git +master:refs/remotes/shallow/master
48 ) &&
49 git log --format=%s shallow/master >actual &&
50 git fsck &&
51 cat <<EOF >expect &&
57 EOF
58 test_cmp expect actual
61 test_expect_success 'push from shallow clone, with grafted roots' '
63 cd shallow2 &&
64 test_must_fail git push ../.git +master:refs/remotes/shallow2/master 2>err &&
65 grep "shallow2/master.*shallow update not allowed" err
66 ) &&
67 test_must_fail git rev-parse shallow2/master &&
68 git fsck
71 test_expect_success 'add new shallow root with receive.updateshallow on' '
72 test_config receive.shallowupdate true &&
74 cd shallow2 &&
75 git push ../.git +master:refs/remotes/shallow2/master
76 ) &&
77 git log --format=%s shallow2/master >actual &&
78 git fsck &&
79 cat <<EOF >expect &&
82 EOF
83 test_cmp expect actual
86 test_expect_success 'push from shallow to shallow' '
88 cd shallow &&
89 git --git-dir=../shallow2/.git config receive.shallowupdate true &&
90 git push ../shallow2/.git +master:refs/remotes/shallow/master &&
91 git --git-dir=../shallow2/.git config receive.shallowupdate false
92 ) &&
94 cd shallow2 &&
95 git log --format=%s shallow/master >actual &&
96 git fsck &&
97 cat <<EOF >expect &&
102 test_cmp expect actual
106 test_expect_success 'push from full to shallow' '
107 ! git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) &&
108 commit 1 &&
109 git push shallow2/.git +master:refs/remotes/top/master &&
111 cd shallow2 &&
112 git log --format=%s top/master >actual &&
113 git fsck &&
114 cat <<EOF >expect &&
119 test_cmp expect actual &&
120 git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
123 test_done