1#!/bin/sh23test_description='push from/to a shallow clone'45. ./test-lib.sh67commit() {8echo "$1" >tracked &&9git add tracked &&10git commit -m "$1"11}1213test_expect_success 'setup' '14git config --global transfer.fsckObjects true &&15commit 1 &&16commit 2 &&17commit 3 &&18commit 4 &&19git clone . full &&20(21git init full-abc &&22cd full-abc &&23commit a &&24commit b &&25commit c26) &&27git clone --no-local --depth=2 .git shallow &&28git --git-dir=shallow/.git log --format=%s >actual &&29cat <<EOF >expect &&30431332EOF33test_cmp expect actual &&34git clone --no-local --depth=2 full-abc/.git shallow2 &&35git --git-dir=shallow2/.git log --format=%s >actual &&36cat <<EOF >expect &&37c38b39EOF40test_cmp expect actual41'4243test_expect_success 'push from shallow clone' '44(45cd shallow &&46commit 5 &&47git push ../.git +master:refs/remotes/shallow/master48) &&49git log --format=%s shallow/master >actual &&50git fsck &&51cat <<EOF >expect &&52553454355256157EOF58test_cmp expect actual59'6061test_expect_success 'push from shallow clone, with grafted roots' '62(63cd shallow2 &&64test_must_fail git push ../.git +master:refs/remotes/shallow2/master 2>err &&65grep "shallow2/master.*shallow update not allowed" err66) &&67test_must_fail git rev-parse shallow2/master &&68git fsck69'7071test_expect_success 'add new shallow root with receive.updateshallow on' '72test_config receive.shallowupdate true &&73(74cd shallow2 &&75git push ../.git +master:refs/remotes/shallow2/master76) &&77git log --format=%s shallow2/master >actual &&78git fsck &&79cat <<EOF >expect &&80c81b82EOF83test_cmp expect actual84'8586test_expect_success 'push from shallow to shallow' '87(88cd shallow &&89git --git-dir=../shallow2/.git config receive.shallowupdate true &&90git push ../shallow2/.git +master:refs/remotes/shallow/master &&91git --git-dir=../shallow2/.git config receive.shallowupdate false92) &&93(94cd shallow2 &&95git log --format=%s shallow/master >actual &&96git fsck &&97cat <<EOF >expect &&9859941003101EOF102test_cmp expect actual103)104'105106test_expect_success 'push from full to shallow' '107! git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) &&108commit 1 &&109git push shallow2/.git +master:refs/remotes/top/master &&110(111cd shallow2 &&112git log --format=%s top/master >actual &&113git fsck &&114cat <<EOF >expect &&115111641173118EOF119test_cmp expect actual &&120git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null121)122'123test_done