]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5538-push-shallow.sh
Start the 2.46 cycle
[thirdparty/git.git] / t / t5538-push-shallow.sh
CommitLineData
5dbd7676
NTND
1#!/bin/sh
2
3test_description='push from/to a shallow clone'
4
3ac8f630 5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
5dbd7676
NTND
8. ./test-lib.sh
9
10commit() {
11 echo "$1" >tracked &&
12 git add tracked &&
13 git commit -m "$1"
14}
15
16test_expect_success 'setup' '
17 git config --global transfer.fsckObjects true &&
18 commit 1 &&
19 commit 2 &&
20 commit 3 &&
21 commit 4 &&
c29a7b8b 22 git clone . full &&
5dbd7676
NTND
23 (
24 git init full-abc &&
25 cd full-abc &&
26 commit a &&
27 commit b &&
28 commit c
29 ) &&
30 git clone --no-local --depth=2 .git shallow &&
31 git --git-dir=shallow/.git log --format=%s >actual &&
32 cat <<EOF >expect &&
334
343
35EOF
36 test_cmp expect actual &&
37 git clone --no-local --depth=2 full-abc/.git shallow2 &&
38 git --git-dir=shallow2/.git log --format=%s >actual &&
39 cat <<EOF >expect &&
40c
41b
42EOF
43 test_cmp expect actual
44'
45
46test_expect_success 'push from shallow clone' '
47 (
48 cd shallow &&
49 commit 5 &&
3ac8f630 50 git push ../.git +main:refs/remotes/shallow/main
5dbd7676 51 ) &&
3ac8f630 52 git log --format=%s shallow/main >actual &&
5dbd7676
NTND
53 git fsck &&
54 cat <<EOF >expect &&
555
564
573
582
591
60EOF
61 test_cmp expect actual
62'
63
64test_expect_success 'push from shallow clone, with grafted roots' '
65 (
66 cd shallow2 &&
3ac8f630
JS
67 test_must_fail git push ../.git +main:refs/remotes/shallow2/main 2>err &&
68 grep "shallow2/main.*shallow update not allowed" err
5dbd7676 69 ) &&
3ac8f630 70 test_must_fail git rev-parse shallow2/main &&
5dbd7676
NTND
71 git fsck
72'
73
0a1bc12b
NTND
74test_expect_success 'add new shallow root with receive.updateshallow on' '
75 test_config receive.shallowupdate true &&
76 (
77 cd shallow2 &&
3ac8f630 78 git push ../.git +main:refs/remotes/shallow2/main
0a1bc12b 79 ) &&
3ac8f630 80 git log --format=%s shallow2/main >actual &&
0a1bc12b
NTND
81 git fsck &&
82 cat <<EOF >expect &&
83c
84b
85EOF
86 test_cmp expect actual
87'
88
b016918b
NTND
89test_expect_success 'push from shallow to shallow' '
90 (
91 cd shallow &&
92 git --git-dir=../shallow2/.git config receive.shallowupdate true &&
3ac8f630 93 git push ../shallow2/.git +main:refs/remotes/shallow/main &&
b016918b
NTND
94 git --git-dir=../shallow2/.git config receive.shallowupdate false
95 ) &&
96 (
97 cd shallow2 &&
3ac8f630 98 git log --format=%s shallow/main >actual &&
b016918b
NTND
99 git fsck &&
100 cat <<EOF >expect &&
1015
1024
1033
104EOF
105 test_cmp expect actual
106 )
107'
108
109test_expect_success 'push from full to shallow' '
752f505c 110 ! git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) &&
b016918b 111 commit 1 &&
3ac8f630 112 git push shallow2/.git +main:refs/remotes/top/main &&
b016918b
NTND
113 (
114 cd shallow2 &&
3ac8f630 115 git log --format=%s top/main >actual &&
b016918b
NTND
116 git fsck &&
117 cat <<EOF >expect &&
1181
1194
1203
121EOF
122 test_cmp expect actual &&
752f505c 123 git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
b016918b
NTND
124 )
125'
5dbd7676 126test_done