Merge branch 'dl/subtree-avoid-tricky-echo'
[git] / t / t9818-git-p4-block.sh
1 #!/bin/sh
2
3 test_description='git p4 fetching changes in multiple blocks'
4
5 . ./lib-git-p4.sh
6
7 test_expect_success 'start p4d' '
8         start_p4d
9 '
10
11 test_expect_success 'Create a repo with ~100 changes' '
12         (
13                 cd "$cli" &&
14                 >file.txt &&
15                 p4 add file.txt &&
16                 p4 submit -d "Add file.txt" &&
17                 for i in $(test_seq 0 9)
18                 do
19                         >outer$i.txt &&
20                         p4 add outer$i.txt &&
21                         p4 submit -d "Adding outer$i.txt" &&
22                         for j in $(test_seq 0 9)
23                         do
24                                 p4 edit file.txt &&
25                                 echo $i$j >file.txt &&
26                                 p4 submit -d "Commit $i$j" || exit
27                         done || exit
28                 done
29         )
30 '
31
32 test_expect_success 'Clone the repo' '
33         git p4 clone --dest="$git" --changes-block-size=10 --verbose //depot@all
34 '
35
36 test_expect_success 'All files are present' '
37         echo file.txt >expected &&
38         test_write_lines outer0.txt outer1.txt outer2.txt outer3.txt outer4.txt >>expected &&
39         test_write_lines outer5.txt outer6.txt outer7.txt outer8.txt outer9.txt >>expected &&
40         ls "$git" >current &&
41         test_cmp expected current
42 '
43
44 test_expect_success 'file.txt is correct' '
45         echo 99 >expected &&
46         test_cmp expected "$git/file.txt"
47 '
48
49 test_expect_success 'Correct number of commits' '
50         (cd "$git" && git log --oneline) >log &&
51         test_line_count = 111 log
52 '
53
54 test_expect_success 'Previous version of file.txt is correct' '
55         (cd "$git" && git checkout HEAD^^) &&
56         echo 97 >expected &&
57         test_cmp expected "$git/file.txt"
58 '
59
60 test_expect_success 'kill p4d' '
61         kill_p4d
62 '
63
64 test_done