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
16 test_expect_success 'setup' '
17 git config --global transfer.fsckObjects true &&
30 git clone --no-local --depth=2 .git shallow &&
31 git --git-dir=shallow/.git log --format=%s >actual &&
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 &&
43 test_cmp expect actual
46 test_expect_success 'push from shallow clone' '
50 git push ../.git +main:refs/remotes/shallow/main
52 git log --format=%s shallow/main >actual &&
61 test_cmp expect actual
64 test_expect_success 'push from shallow clone, with grafted roots' '
67 test_must_fail git push ../.git +main:refs/remotes/shallow2/main 2>err &&
68 grep "shallow2/main.*shallow update not allowed" err
70 test_must_fail git rev-parse shallow2/main &&
74 test_expect_success 'add new shallow root with receive.updateshallow on' '
75 test_config receive.shallowupdate true &&
78 git push ../.git +main:refs/remotes/shallow2/main
80 git log --format=%s shallow2/main >actual &&
86 test_cmp expect actual
89 test_expect_success 'push from shallow to shallow' '
92 git --git-dir=../shallow2/.git config receive.shallowupdate true &&
93 git push ../shallow2/.git +main:refs/remotes/shallow/main &&
94 git --git-dir=../shallow2/.git config receive.shallowupdate false
98 git log --format=%s shallow/main >actual &&
105 test_cmp expect actual
109 test_expect_success 'push from full to shallow' '
110 ! git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) &&
112 git push shallow2/.git +main:refs/remotes/top/main &&
115 git log --format=%s top/main >actual &&
122 test_cmp expect actual &&
123 git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null