Skip to content

Commit b2a9f4d

Browse files
grnchgitster
authored andcommitted
fetch-pack: test cases for the new --stdin option
These test cases focus only on testing the parsing of refs on stdin, without bothering with the rest of the fetch-pack machinery. We pass in the refs using different combinations of command line and stdin and then we watch fetch-pack's stdout to see whether it prints all the refs we specified (but we ignore their order). Signed-off-by: Ivan Todoroski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8150749 commit b2a9f4d

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

t/t5500-fetch-pack.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,70 @@ test_expect_success 'clone shallow object count' '
248248
grep "^count: 52" count.shallow
249249
'
250250

251+
test_expect_success 'setup tests for the --stdin parameter' '
252+
for head in C D E F
253+
do
254+
add $head
255+
done &&
256+
for head in A B C D E F
257+
do
258+
git tag $head $head
259+
done &&
260+
cat >input <<-\EOF
261+
refs/heads/C
262+
refs/heads/A
263+
refs/heads/D
264+
refs/tags/C
265+
refs/heads/B
266+
refs/tags/A
267+
refs/heads/E
268+
refs/tags/B
269+
refs/tags/E
270+
refs/tags/D
271+
EOF
272+
sort <input >expect &&
273+
(
274+
echo refs/heads/E &&
275+
echo refs/tags/E &&
276+
cat input
277+
) >input.dup
278+
'
279+
280+
test_expect_success 'fetch refs from cmdline' '
281+
(
282+
cd client &&
283+
git fetch-pack --no-progress .. $(cat ../input)
284+
) >output &&
285+
cut -d " " -f 2 <output | sort >actual &&
286+
test_cmp expect actual
287+
'
288+
289+
test_expect_success 'fetch refs from stdin' '
290+
(
291+
cd client &&
292+
git fetch-pack --stdin --no-progress .. <../input
293+
) >output &&
294+
cut -d " " -f 2 <output | sort >actual &&
295+
test_cmp expect actual
296+
'
297+
298+
test_expect_success 'fetch mixed refs from cmdline and stdin' '
299+
(
300+
cd client &&
301+
tail -n +5 ../input |
302+
git fetch-pack --stdin --no-progress .. $(head -n 4 ../input)
303+
) >output &&
304+
cut -d " " -f 2 <output | sort >actual &&
305+
test_cmp expect actual
306+
'
307+
308+
test_expect_success 'test duplicate refs from stdin' '
309+
(
310+
cd client &&
311+
test_must_fail git fetch-pack --stdin --no-progress .. <../input.dup
312+
) >output &&
313+
cut -d " " -f 2 <output | sort >actual &&
314+
test_cmp expect actual
315+
'
316+
251317
test_done

0 commit comments

Comments
 (0)