read-cache: touch shared index files when used
[alt-git.git] / t / t5537-fetch-shallow.sh
blobdf8d2f095a40f524b8318b98a7c4fb085d8010f4
1 #!/bin/sh
3 test_description='fetch/clone from a shallow clone'
5 . ./test-lib.sh
7 commit() {
8 echo "$1" >tracked &&
9 git add tracked &&
10 git commit -m "$1"
13 test_expect_success 'setup' '
14 commit 1 &&
15 commit 2 &&
16 commit 3 &&
17 commit 4 &&
18 git config --global transfer.fsckObjects true
21 test_expect_success 'setup shallow clone' '
22 git clone --no-local --depth=2 .git shallow &&
23 git --git-dir=shallow/.git log --format=%s >actual &&
24 cat <<EOF >expect &&
27 EOF
28 test_cmp expect actual
31 test_expect_success 'clone from shallow clone' '
32 git clone --no-local shallow shallow2 &&
34 cd shallow2 &&
35 git fsck &&
36 git log --format=%s >actual &&
37 cat <<EOF >expect &&
40 EOF
41 test_cmp expect actual
45 test_expect_success 'fetch from shallow clone' '
47 cd shallow &&
48 commit 5
49 ) &&
51 cd shallow2 &&
52 git fetch &&
53 git fsck &&
54 git log --format=%s origin/master >actual &&
55 cat <<EOF >expect &&
59 EOF
60 test_cmp expect actual
64 test_expect_success 'fetch --depth from shallow clone' '
66 cd shallow &&
67 commit 6
68 ) &&
70 cd shallow2 &&
71 git fetch --depth=2 &&
72 git fsck &&
73 git log --format=%s origin/master >actual &&
74 cat <<EOF >expect &&
77 EOF
78 test_cmp expect actual
82 test_expect_success 'fetch --unshallow from shallow clone' '
84 cd shallow2 &&
85 git fetch --unshallow &&
86 git fsck &&
87 git log --format=%s origin/master >actual &&
88 cat <<EOF >expect &&
93 EOF
94 test_cmp expect actual
98 test_expect_success 'fetch something upstream has but hidden by clients shallow boundaries' '
99 # the blob "1" is available in .git but hidden by the
100 # shallow2/.git/shallow and it should be resent
101 ! git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null &&
102 echo 1 >1.t &&
103 git add 1.t &&
104 git commit -m add-1-back &&
106 cd shallow2 &&
107 git fetch ../.git +refs/heads/master:refs/remotes/top/master &&
108 git fsck &&
109 git log --format=%s top/master >actual &&
110 cat <<EOF >expect &&
111 add-1-back
115 test_cmp expect actual
116 ) &&
117 git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
121 test_expect_success 'fetch that requires changes in .git/shallow is filtered' '
123 cd shallow &&
124 git checkout --orphan no-shallow &&
125 commit no-shallow
126 ) &&
127 git init notshallow &&
129 cd notshallow &&
130 git fetch ../shallow/.git refs/heads/*:refs/remotes/shallow/*&&
131 git for-each-ref --format="%(refname)" >actual.refs &&
132 cat <<EOF >expect.refs &&
133 refs/remotes/shallow/no-shallow
135 test_cmp expect.refs actual.refs &&
136 git log --format=%s shallow/no-shallow >actual &&
137 cat <<EOF >expect &&
138 no-shallow
140 test_cmp expect actual
144 test_expect_success 'fetch --update-shallow' '
146 cd shallow &&
147 git checkout master &&
148 commit 7 &&
149 git tag -m foo heavy-tag HEAD^ &&
150 git tag light-tag HEAD^:tracked
151 ) &&
153 cd notshallow &&
154 git fetch --update-shallow ../shallow/.git refs/heads/*:refs/remotes/shallow/* &&
155 git fsck &&
156 git for-each-ref --sort=refname --format="%(refname)" >actual.refs &&
157 cat <<EOF >expect.refs &&
158 refs/remotes/shallow/master
159 refs/remotes/shallow/no-shallow
160 refs/tags/heavy-tag
161 refs/tags/light-tag
163 test_cmp expect.refs actual.refs &&
164 git log --format=%s shallow/master >actual &&
165 cat <<EOF >expect &&
172 test_cmp expect actual
176 test_expect_success POSIXPERM,SANITY 'shallow fetch from a read-only repo' '
177 cp -R .git read-only.git &&
178 find read-only.git -print | xargs chmod -w &&
179 test_when_finished "find read-only.git -type d -print | xargs chmod +w" &&
180 git clone --no-local --depth=2 read-only.git from-read-only &&
181 git --git-dir=from-read-only/.git log --format=%s >actual &&
182 cat >expect <<EOF &&
183 add-1-back
186 test_cmp expect actual
189 test_done