Jens Lehmann | ea5070c | 2011-05-25 22:10:41 +0200 | [diff] [blame] | 1 | # Helper functions to check if read-tree would succeed/fail as expected with |
| 2 | # and without the dry-run option. They also test that the dry-run does not |
| 3 | # write the index and that together with -u it doesn't touch the work tree. |
| 4 | # |
| 5 | read_tree_must_succeed () { |
Junio C Hamano | 76da5b1 | 2013-11-01 14:55:17 -0700 | [diff] [blame] | 6 | git ls-files -s >pre-dry-run && |
| 7 | git read-tree -n "$@" && |
| 8 | git ls-files -s >post-dry-run && |
| 9 | test_cmp pre-dry-run post-dry-run && |
| 10 | git read-tree "$@" |
Jens Lehmann | ea5070c | 2011-05-25 22:10:41 +0200 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | read_tree_must_fail () { |
Junio C Hamano | 76da5b1 | 2013-11-01 14:55:17 -0700 | [diff] [blame] | 14 | git ls-files -s >pre-dry-run && |
| 15 | test_must_fail git read-tree -n "$@" && |
| 16 | git ls-files -s >post-dry-run && |
| 17 | test_cmp pre-dry-run post-dry-run && |
| 18 | test_must_fail git read-tree "$@" |
Jens Lehmann | ea5070c | 2011-05-25 22:10:41 +0200 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | read_tree_u_must_succeed () { |
Junio C Hamano | 76da5b1 | 2013-11-01 14:55:17 -0700 | [diff] [blame] | 22 | git ls-files -s >pre-dry-run && |
| 23 | git diff-files -p >pre-dry-run-wt && |
| 24 | git read-tree -n "$@" && |
| 25 | git ls-files -s >post-dry-run && |
| 26 | git diff-files -p >post-dry-run-wt && |
| 27 | test_cmp pre-dry-run post-dry-run && |
| 28 | test_cmp pre-dry-run-wt post-dry-run-wt && |
| 29 | git read-tree "$@" |
Jens Lehmann | ea5070c | 2011-05-25 22:10:41 +0200 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | read_tree_u_must_fail () { |
Junio C Hamano | 76da5b1 | 2013-11-01 14:55:17 -0700 | [diff] [blame] | 33 | git ls-files -s >pre-dry-run && |
| 34 | git diff-files -p >pre-dry-run-wt && |
| 35 | test_must_fail git read-tree -n "$@" && |
| 36 | git ls-files -s >post-dry-run && |
| 37 | git diff-files -p >post-dry-run-wt && |
| 38 | test_cmp pre-dry-run post-dry-run && |
| 39 | test_cmp pre-dry-run-wt post-dry-run-wt && |
| 40 | test_must_fail git read-tree "$@" |
Jens Lehmann | ea5070c | 2011-05-25 22:10:41 +0200 | [diff] [blame] | 41 | } |