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