archive: handle commits with an empty tree
[git/jnareb-git.git] / t / lib-read-tree.sh
blobabc2c6f57fe29d124455227a16e241c49ae40c5c
1 #!/bin/sh
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.
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 "$@"
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 "$@"
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 "$@"
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 "$@"