The 20th batch
[alt-git.git] / t / t5538-push-shallow.sh
blob6adc3a20a45b77aea252d7073025f57060c1797e
1 #!/bin/sh
3 test_description='push from/to a shallow clone'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 commit() {
12 echo "$1" >tracked &&
13 git add tracked &&
14 git commit -m "$1"
17 test_expect_success 'setup' '
18 git config --global transfer.fsckObjects true &&
19 commit 1 &&
20 commit 2 &&
21 commit 3 &&
22 commit 4 &&
23 git clone . full &&
25 git init full-abc &&
26 cd full-abc &&
27 commit a &&
28 commit b &&
29 commit c
30 ) &&
31 git clone --no-local --depth=2 .git shallow &&
32 git --git-dir=shallow/.git log --format=%s >actual &&
33 cat <<EOF >expect &&
36 EOF
37 test_cmp expect actual &&
38 git clone --no-local --depth=2 full-abc/.git shallow2 &&
39 git --git-dir=shallow2/.git log --format=%s >actual &&
40 cat <<EOF >expect &&
43 EOF
44 test_cmp expect actual
47 test_expect_success 'push from shallow clone' '
49 cd shallow &&
50 commit 5 &&
51 git push ../.git +main:refs/remotes/shallow/main
52 ) &&
53 git log --format=%s shallow/main >actual &&
54 git fsck &&
55 cat <<EOF >expect &&
61 EOF
62 test_cmp expect actual
65 test_expect_success 'push from shallow clone, with grafted roots' '
67 cd shallow2 &&
68 test_must_fail git push ../.git +main:refs/remotes/shallow2/main 2>err &&
69 grep "shallow2/main.*shallow update not allowed" err
70 ) &&
71 test_must_fail git rev-parse shallow2/main &&
72 git fsck
75 test_expect_success 'add new shallow root with receive.updateshallow on' '
76 test_config receive.shallowupdate true &&
78 cd shallow2 &&
79 git push ../.git +main:refs/remotes/shallow2/main
80 ) &&
81 git log --format=%s shallow2/main >actual &&
82 git fsck &&
83 cat <<EOF >expect &&
86 EOF
87 test_cmp expect actual
90 test_expect_success 'push from shallow to shallow' '
92 cd shallow &&
93 git --git-dir=../shallow2/.git config receive.shallowupdate true &&
94 git push ../shallow2/.git +main:refs/remotes/shallow/main &&
95 git --git-dir=../shallow2/.git config receive.shallowupdate false
96 ) &&
98 cd shallow2 &&
99 git log --format=%s shallow/main >actual &&
100 git fsck &&
101 cat <<EOF >expect &&
106 test_cmp expect actual
110 test_expect_success 'push from full to shallow' '
111 ! git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) &&
112 commit 1 &&
113 git push shallow2/.git +main:refs/remotes/top/main &&
115 cd shallow2 &&
116 git log --format=%s top/main >actual &&
117 git fsck &&
118 cat <<EOF >expect &&
123 test_cmp expect actual &&
124 git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
127 test_done