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