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
17 test_expect_success
'setup' '
18 git config --global transfer.fsckObjects true &&
31 git clone --no-local --depth=2 .git shallow &&
32 git --git-dir=shallow/.git log --format=%s >actual &&
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 &&
44 test_cmp expect actual
47 test_expect_success
'push from shallow clone' '
51 git push ../.git +main:refs/remotes/shallow/main
53 git log --format=%s shallow/main >actual &&
62 test_cmp expect actual
65 test_expect_success
'push from shallow clone, with grafted roots' '
68 test_must_fail git push ../.git +main:refs/remotes/shallow2/main 2>err &&
69 grep "shallow2/main.*shallow update not allowed" err
71 test_must_fail git rev-parse shallow2/main &&
75 test_expect_success
'add new shallow root with receive.updateshallow on' '
76 test_config receive.shallowupdate true &&
79 git push ../.git +main:refs/remotes/shallow2/main
81 git log --format=%s shallow2/main >actual &&
87 test_cmp expect actual
90 test_expect_success
'push from shallow to 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
99 git log --format=%s shallow/main >actual &&
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) &&
113 git push shallow2/.git +main:refs/remotes/top/main &&
116 git log --format=%s top/main >actual &&
123 test_cmp expect actual &&
124 git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null