blob: b95f4856061da723cbe36bd6955c552bee7a29aa [file] [log] [blame]
Jens Lehmannea5070c2011-05-25 22:10:41 +02001# 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#
5read_tree_must_succeed () {
Junio C Hamano76da5b12013-11-01 14:55:17 -07006 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 Lehmannea5070c2011-05-25 22:10:41 +020011}
12
13read_tree_must_fail () {
Junio C Hamano76da5b12013-11-01 14:55:17 -070014 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 Lehmannea5070c2011-05-25 22:10:41 +020019}
20
21read_tree_u_must_succeed () {
Junio C Hamano76da5b12013-11-01 14:55:17 -070022 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 Lehmannea5070c2011-05-25 22:10:41 +020030}
31
32read_tree_u_must_fail () {
Junio C Hamano76da5b12013-11-01 14:55:17 -070033 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 Lehmannea5070c2011-05-25 22:10:41 +020041}