1#!/bin/sh
23
test_description='push from/to a shallow clone'
45
. ./test-lib.sh
67
commit() {
8echo "$1" >tracked &&
9git add tracked &&
10git commit -m "$1"
11}
1213
test_expect_success 'setup' '
14git config --global transfer.fsckObjects true &&
15commit 1 &&
16commit 2 &&
17commit 3 &&
18commit 4 &&
19(
20git init full-abc &&
21cd full-abc &&
22commit a &&
23commit b &&
24commit c
25) &&
26git clone --no-local --depth=2 .git shallow &&
27git --git-dir=shallow/.git log --format=%s >actual &&
28cat <<EOF >expect &&
294
303
31EOF
32test_cmp expect actual &&
33git clone --no-local --depth=2 full-abc/.git shallow2 &&
34git --git-dir=shallow2/.git log --format=%s >actual &&
35cat <<EOF >expect &&
36c
37b
38EOF
39test_cmp expect actual
40'
4142
test_expect_success 'push from shallow clone' '
43(
44cd shallow &&
45commit 5 &&
46git push ../.git +master:refs/remotes/shallow/master
47) &&
48git log --format=%s shallow/master >actual &&
49git fsck &&
50cat <<EOF >expect &&
515
524
533
542
551
56EOF
57test_cmp expect actual
58'
5960
test_expect_success 'push from shallow clone, with grafted roots' '
61(
62cd shallow2 &&
63test_must_fail git push ../.git +master:refs/remotes/shallow2/master 2>err &&
64grep "shallow2/master.*shallow update not allowed" err
65) &&
66test_must_fail git rev-parse shallow2/master &&
67git fsck
68'
6970
test_expect_success 'add new shallow root with receive.updateshallow on' '
71test_config receive.shallowupdate true &&
72(
73cd shallow2 &&
74git push ../.git +master:refs/remotes/shallow2/master
75) &&
76git log --format=%s shallow2/master >actual &&
77git fsck &&
78cat <<EOF >expect &&
79c
80b
81EOF
82test_cmp expect actual
83'
8485
test_expect_success 'push from shallow to shallow' '
86(
87cd shallow &&
88git --git-dir=../shallow2/.git config receive.shallowupdate true &&
89git push ../shallow2/.git +master:refs/remotes/shallow/master &&
90git --git-dir=../shallow2/.git config receive.shallowupdate false
91) &&
92(
93cd shallow2 &&
94git log --format=%s shallow/master >actual &&
95git fsck &&
96cat <<EOF >expect &&
975
984
993
100EOF
101test_cmp expect actual
102)
103'
104105
test_expect_success 'push from full to shallow' '
106! git --git-dir=shallow2/.git cat-file blob `echo 1|git hash-object --stdin` &&
107commit 1 &&
108git push shallow2/.git +master:refs/remotes/top/master &&
109(
110cd shallow2 &&
111git log --format=%s top/master >actual &&
112git fsck &&
113cat <<EOF >expect &&
1141
1154
1163
117EOF
118test_cmp expect actual &&
119git cat-file blob `echo 1|git hash-object --stdin` >/dev/null
120)
121'
122123
test_done