Junio C Hamano | d5db6c9 | 2006-12-19 18:25:32 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 3 | test_description='git rev-list --max-count and --skip test' |
Junio C Hamano | d5db6c9 | 2006-12-19 18:25:32 -0800 | [diff] [blame] | 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" ; \ |
| 12 | done |
| 13 | ' |
| 14 | |
| 15 | test_expect_success 'no options' ' |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 16 | test $(git rev-list HEAD | wc -l) = 5 |
Junio C Hamano | d5db6c9 | 2006-12-19 18:25:32 -0800 | [diff] [blame] | 17 | ' |
| 18 | |
| 19 | test_expect_success '--max-count' ' |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 20 | test $(git rev-list HEAD --max-count=0 | wc -l) = 0 && |
| 21 | test $(git rev-list HEAD --max-count=3 | wc -l) = 3 && |
| 22 | test $(git rev-list HEAD --max-count=5 | wc -l) = 5 && |
| 23 | test $(git rev-list HEAD --max-count=10 | wc -l) = 5 |
Junio C Hamano | d5db6c9 | 2006-12-19 18:25:32 -0800 | [diff] [blame] | 24 | ' |
| 25 | |
| 26 | test_expect_success '--max-count all forms' ' |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 27 | test $(git rev-list HEAD --max-count=1 | wc -l) = 1 && |
| 28 | test $(git rev-list HEAD -1 | wc -l) = 1 && |
| 29 | test $(git rev-list HEAD -n1 | wc -l) = 1 && |
| 30 | test $(git rev-list HEAD -n 1 | wc -l) = 1 |
Junio C Hamano | d5db6c9 | 2006-12-19 18:25:32 -0800 | [diff] [blame] | 31 | ' |
| 32 | |
| 33 | test_expect_success '--skip' ' |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 34 | test $(git rev-list HEAD --skip=0 | wc -l) = 5 && |
| 35 | test $(git rev-list HEAD --skip=3 | wc -l) = 2 && |
| 36 | test $(git rev-list HEAD --skip=5 | wc -l) = 0 && |
| 37 | test $(git rev-list HEAD --skip=10 | wc -l) = 0 |
Junio C Hamano | d5db6c9 | 2006-12-19 18:25:32 -0800 | [diff] [blame] | 38 | ' |
| 39 | |
| 40 | test_expect_success '--skip --max-count' ' |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 41 | test $(git rev-list HEAD --skip=0 --max-count=0 | wc -l) = 0 && |
| 42 | test $(git rev-list HEAD --skip=0 --max-count=10 | wc -l) = 5 && |
| 43 | test $(git rev-list HEAD --skip=3 --max-count=0 | wc -l) = 0 && |
| 44 | test $(git rev-list HEAD --skip=3 --max-count=1 | wc -l) = 1 && |
| 45 | test $(git rev-list HEAD --skip=3 --max-count=2 | wc -l) = 2 && |
| 46 | test $(git rev-list HEAD --skip=3 --max-count=10 | wc -l) = 2 && |
| 47 | test $(git rev-list HEAD --skip=5 --max-count=10 | wc -l) = 0 && |
| 48 | test $(git rev-list HEAD --skip=10 --max-count=10 | wc -l) = 0 |
Junio C Hamano | d5db6c9 | 2006-12-19 18:25:32 -0800 | [diff] [blame] | 49 | ' |
| 50 | |
| 51 | test_done |