3 test_description
='git rev-list --max-count and --skip test'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup' '
9 for n in 1 2 3 4 5 ; do
12 git commit -m "$n" || return 1
16 test_expect_success
'no options' '
17 test $(git rev-list HEAD | wc -l) = 5
20 test_expect_success
'--max-count' '
21 test $(git rev-list HEAD --max-count=0 | wc -l) = 0 &&
22 test $(git rev-list HEAD --max-count=3 | wc -l) = 3 &&
23 test $(git rev-list HEAD --max-count=5 | wc -l) = 5 &&
24 test $(git rev-list HEAD --max-count=10 | wc -l) = 5
27 test_expect_success
'--max-count all forms' '
28 test $(git rev-list HEAD --max-count=1 | wc -l) = 1 &&
29 test $(git rev-list HEAD -1 | wc -l) = 1 &&
30 test $(git rev-list HEAD -n1 | wc -l) = 1 &&
31 test $(git rev-list HEAD -n 1 | wc -l) = 1
34 test_expect_success
'--skip' '
35 test $(git rev-list HEAD --skip=0 | wc -l) = 5 &&
36 test $(git rev-list HEAD --skip=3 | wc -l) = 2 &&
37 test $(git rev-list HEAD --skip=5 | wc -l) = 0 &&
38 test $(git rev-list HEAD --skip=10 | wc -l) = 0
41 test_expect_success
'--skip --max-count' '
42 test $(git rev-list HEAD --skip=0 --max-count=0 | wc -l) = 0 &&
43 test $(git rev-list HEAD --skip=0 --max-count=10 | wc -l) = 5 &&
44 test $(git rev-list HEAD --skip=3 --max-count=0 | wc -l) = 0 &&
45 test $(git rev-list HEAD --skip=3 --max-count=1 | wc -l) = 1 &&
46 test $(git rev-list HEAD --skip=3 --max-count=2 | wc -l) = 2 &&
47 test $(git rev-list HEAD --skip=3 --max-count=10 | wc -l) = 2 &&
48 test $(git rev-list HEAD --skip=5 --max-count=10 | wc -l) = 0 &&
49 test $(git rev-list HEAD --skip=10 --max-count=10 | wc -l) = 0