]>
Commit | Line | Data |
---|---|---|
d5db6c9e JH |
1 | #!/bin/sh |
2 | ||
5be60078 | 3 | test_description='git rev-list --max-count and --skip test' |
d5db6c9e | 4 | |
7a98d9ab | 5 | TEST_PASSES_SANITIZE_LEAK=true |
d5db6c9e JH |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success 'setup' ' | |
74d2f569 ES |
9 | for n in 1 2 3 4 5 ; do |
10 | echo $n > a && | |
11 | git add a && | |
0c51d6b4 | 12 | git commit -m "$n" || return 1 |
d5db6c9e JH |
13 | done |
14 | ' | |
15 | ||
16 | test_expect_success 'no options' ' | |
a182f69d | 17 | test_stdout_line_count = 5 git rev-list HEAD |
d5db6c9e JH |
18 | ' |
19 | ||
20 | test_expect_success '--max-count' ' | |
71a1e948 JH |
21 | test_must_fail git rev-list --max-count=1q HEAD 2>error && |
22 | grep "not an integer" error && | |
23 | ||
a182f69d ÆAB |
24 | test_stdout_line_count = 0 git rev-list HEAD --max-count=0 && |
25 | test_stdout_line_count = 3 git rev-list HEAD --max-count=3 && | |
26 | test_stdout_line_count = 5 git rev-list HEAD --max-count=5 && | |
71a1e948 JH |
27 | test_stdout_line_count = 5 git rev-list HEAD --max-count=10 && |
28 | test_stdout_line_count = 5 git rev-list HEAD --max-count=-1 | |
d5db6c9e JH |
29 | ' |
30 | ||
31 | test_expect_success '--max-count all forms' ' | |
71a1e948 JH |
32 | test_must_fail git rev-list -1q HEAD 2>error && |
33 | grep "not an integer" error && | |
34 | test_must_fail git rev-list --1 HEAD && | |
35 | test_must_fail git rev-list -n 1q HEAD 2>error && | |
36 | grep "not an integer" error && | |
37 | ||
a182f69d ÆAB |
38 | test_stdout_line_count = 1 git rev-list HEAD --max-count=1 && |
39 | test_stdout_line_count = 1 git rev-list HEAD -1 && | |
40 | test_stdout_line_count = 1 git rev-list HEAD -n1 && | |
71a1e948 JH |
41 | test_stdout_line_count = 1 git rev-list HEAD -n 1 && |
42 | test_stdout_line_count = 5 git rev-list HEAD -n -1 | |
d5db6c9e JH |
43 | ' |
44 | ||
45 | test_expect_success '--skip' ' | |
71a1e948 JH |
46 | test_must_fail git rev-list --skip 1q HEAD 2>error && |
47 | grep "not an integer" error && | |
48 | ||
a182f69d ÆAB |
49 | test_stdout_line_count = 5 git rev-list HEAD --skip=0 && |
50 | test_stdout_line_count = 2 git rev-list HEAD --skip=3 && | |
51 | test_stdout_line_count = 0 git rev-list HEAD --skip=5 && | |
52 | test_stdout_line_count = 0 git rev-list HEAD --skip=10 | |
d5db6c9e JH |
53 | ' |
54 | ||
55 | test_expect_success '--skip --max-count' ' | |
a182f69d ÆAB |
56 | test_stdout_line_count = 0 git rev-list HEAD --skip=0 --max-count=0 && |
57 | test_stdout_line_count = 5 git rev-list HEAD --skip=0 --max-count=10 && | |
58 | test_stdout_line_count = 0 git rev-list HEAD --skip=3 --max-count=0 && | |
59 | test_stdout_line_count = 1 git rev-list HEAD --skip=3 --max-count=1 && | |
60 | test_stdout_line_count = 2 git rev-list HEAD --skip=3 --max-count=2 && | |
61 | test_stdout_line_count = 2 git rev-list HEAD --skip=3 --max-count=10 && | |
62 | test_stdout_line_count = 0 git rev-list HEAD --skip=5 --max-count=10 && | |
63 | test_stdout_line_count = 0 git rev-list HEAD --skip=10 --max-count=10 | |
d5db6c9e JH |
64 | ' |
65 | ||
66 | test_done |