@@ -16,7 +16,7 @@ test_expect_success 'setup' '
16
16
commit 3 &&
17
17
commit 4 &&
18
18
git config --global transfer.fsckObjects true &&
19
- test_oid_cache <<-EOF
19
+ test_oid_cache <<-\ EOF
20
20
perl sha1:s/0034shallow %s/0036unshallow %s/
21
21
perl sha256:s/004cshallow %s/004eunshallow %s/
22
22
EOF
@@ -25,10 +25,7 @@ test_expect_success 'setup' '
25
25
test_expect_success ' setup shallow clone' '
26
26
git clone --no-local --depth=2 .git shallow &&
27
27
git --git-dir=shallow/.git log --format=%s >actual &&
28
- cat <<EOF >expect &&
29
- 4
30
- 3
31
- EOF
28
+ test_write_lines 4 3 >expect &&
32
29
test_cmp expect actual
33
30
'
34
31
@@ -38,10 +35,7 @@ test_expect_success 'clone from shallow clone' '
38
35
cd shallow2 &&
39
36
git fsck &&
40
37
git log --format=%s >actual &&
41
- cat <<EOF >expect &&
42
- 4
43
- 3
44
- EOF
38
+ test_write_lines 4 3 >expect &&
45
39
test_cmp expect actual
46
40
)
47
41
'
@@ -56,11 +50,7 @@ test_expect_success 'fetch from shallow clone' '
56
50
git fetch &&
57
51
git fsck &&
58
52
git log --format=%s origin/master >actual &&
59
- cat <<EOF >expect &&
60
- 5
61
- 4
62
- 3
63
- EOF
53
+ test_write_lines 5 4 3 >expect &&
64
54
test_cmp expect actual
65
55
)
66
56
'
@@ -75,10 +65,7 @@ test_expect_success 'fetch --depth from shallow clone' '
75
65
git fetch --depth=2 &&
76
66
git fsck &&
77
67
git log --format=%s origin/master >actual &&
78
- cat <<EOF >expect &&
79
- 6
80
- 5
81
- EOF
68
+ test_write_lines 6 5 >expect &&
82
69
test_cmp expect actual
83
70
)
84
71
'
@@ -89,12 +76,7 @@ test_expect_success 'fetch --unshallow from shallow clone' '
89
76
git fetch --unshallow &&
90
77
git fsck &&
91
78
git log --format=%s origin/master >actual &&
92
- cat <<EOF >expect &&
93
- 6
94
- 5
95
- 4
96
- 3
97
- EOF
79
+ test_write_lines 6 5 4 3 >expect &&
98
80
test_cmp expect actual
99
81
)
100
82
'
@@ -111,15 +93,10 @@ test_expect_success 'fetch something upstream has but hidden by clients shallow
111
93
git fetch ../.git +refs/heads/master:refs/remotes/top/master &&
112
94
git fsck &&
113
95
git log --format=%s top/master >actual &&
114
- cat <<EOF >expect &&
115
- add-1-back
116
- 4
117
- 3
118
- EOF
96
+ test_write_lines add-1-back 4 3 >expect &&
119
97
test_cmp expect actual
120
98
) &&
121
99
git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
122
-
123
100
'
124
101
125
102
test_expect_success ' fetch that requires changes in .git/shallow is filtered' '
@@ -133,14 +110,10 @@ test_expect_success 'fetch that requires changes in .git/shallow is filtered' '
133
110
cd notshallow &&
134
111
git fetch ../shallow/.git refs/heads/*:refs/remotes/shallow/* &&
135
112
git for-each-ref --format="%(refname)" >actual.refs &&
136
- cat <<EOF >expect.refs &&
137
- refs/remotes/shallow/no-shallow
138
- EOF
113
+ echo refs/remotes/shallow/no-shallow >expect.refs &&
139
114
test_cmp expect.refs actual.refs &&
140
115
git log --format=%s shallow/no-shallow >actual &&
141
- cat <<EOF >expect &&
142
- no-shallow
143
- EOF
116
+ echo no-shallow >expect &&
144
117
test_cmp expect actual
145
118
)
146
119
'
@@ -158,21 +131,44 @@ test_expect_success 'fetch --update-shallow' '
158
131
git fetch --update-shallow ../shallow/.git refs/heads/*:refs/remotes/shallow/* &&
159
132
git fsck &&
160
133
git for-each-ref --sort=refname --format="%(refname)" >actual.refs &&
161
- cat <<EOF >expect.refs &&
162
- refs/remotes/shallow/master
163
- refs/remotes/shallow/no-shallow
164
- refs/tags/heavy-tag
165
- refs/tags/light-tag
166
- EOF
134
+ cat <<-\EOF >expect.refs &&
135
+ refs/remotes/shallow/master
136
+ refs/remotes/shallow/no-shallow
137
+ refs/tags/heavy-tag
138
+ refs/tags/light-tag
139
+ EOF
140
+ test_cmp expect.refs actual.refs &&
141
+ git log --format=%s shallow/master >actual &&
142
+ test_write_lines 7 6 5 4 3 >expect &&
143
+ test_cmp expect actual
144
+ )
145
+ '
146
+
147
+ test_expect_success ' fetch --update-shallow (with fetch.writeCommitGraph)' '
148
+ (
149
+ cd shallow &&
150
+ git checkout master &&
151
+ commit 8 &&
152
+ git tag -m foo heavy-tag-for-graph HEAD^ &&
153
+ git tag light-tag-for-graph HEAD^:tracked
154
+ ) &&
155
+ test_config -C notshallow fetch.writeCommitGraph true &&
156
+ (
157
+ cd notshallow &&
158
+ git fetch --update-shallow ../shallow/.git refs/heads/*:refs/remotes/shallow/* &&
159
+ git fsck &&
160
+ git for-each-ref --sort=refname --format="%(refname)" >actual.refs &&
161
+ cat <<-EOF >expect.refs &&
162
+ refs/remotes/shallow/master
163
+ refs/remotes/shallow/no-shallow
164
+ refs/tags/heavy-tag
165
+ refs/tags/heavy-tag-for-graph
166
+ refs/tags/light-tag
167
+ refs/tags/light-tag-for-graph
168
+ EOF
167
169
test_cmp expect.refs actual.refs &&
168
170
git log --format=%s shallow/master >actual &&
169
- cat <<EOF >expect &&
170
- 7
171
- 6
172
- 5
173
- 4
174
- 3
175
- EOF
171
+ test_write_lines 8 7 6 5 4 3 >expect &&
176
172
test_cmp expect actual
177
173
)
178
174
'
@@ -183,10 +179,7 @@ test_expect_success POSIXPERM,SANITY 'shallow fetch from a read-only repo' '
183
179
find read-only.git -print | xargs chmod -w &&
184
180
git clone --no-local --depth=2 read-only.git from-read-only &&
185
181
git --git-dir=from-read-only/.git log --format=%s >actual &&
186
- cat >expect <<EOF &&
187
- add-1-back
188
- 4
189
- EOF
182
+ test_write_lines add-1-back 4 >expect &&
190
183
test_cmp expect actual
191
184
'
192
185
0 commit comments