]>
Commit | Line | Data |
---|---|---|
455923e0 ÆAB |
1 | #!/bin/sh |
2 | ||
3 | test_description='ls-tree --format' | |
4 | ||
5 | TEST_PASSES_SANITIZE_LEAK=true | |
6 | . ./test-lib.sh | |
1d232d38 | 7 | . "$TEST_DIRECTORY"/lib-t3100.sh |
455923e0 ÆAB |
8 | |
9 | test_expect_success 'ls-tree --format usage' ' | |
10 | test_expect_code 129 git ls-tree --format=fmt -l HEAD && | |
11 | test_expect_code 129 git ls-tree --format=fmt --name-only HEAD && | |
12 | test_expect_code 129 git ls-tree --format=fmt --name-status HEAD | |
13 | ' | |
14 | ||
15 | test_expect_success 'setup' ' | |
1d232d38 | 16 | setup_basic_ls_tree_data |
455923e0 ÆAB |
17 | ' |
18 | ||
19 | test_ls_tree_format () { | |
20 | format=$1 && | |
21 | opts=$2 && | |
22 | fmtopts=$3 && | |
455923e0 ÆAB |
23 | |
24 | test_expect_success "ls-tree '--format=<$format>' is like options '$opts $fmtopts'" ' | |
25 | git ls-tree $opts -r HEAD >expect && | |
26 | git ls-tree --format="$format" -r $fmtopts HEAD >actual && | |
27 | test_cmp expect actual | |
28 | ' | |
29 | ||
30 | test_expect_success "ls-tree '--format=<$format>' on optimized v.s. non-optimized path" ' | |
31 | git ls-tree --format="$format" -r $fmtopts HEAD >expect && | |
32 | git ls-tree --format="> $format" -r $fmtopts HEAD >actual.raw && | |
33 | sed "s/^> //" >actual <actual.raw && | |
34 | test_cmp expect actual | |
35 | ' | |
36 | } | |
37 | ||
16fb5c54 RS |
38 | test_expect_success "ls-tree --format='%(path) %(path) %(path)' HEAD top-file" ' |
39 | git ls-tree --format="%(path) %(path) %(path)" HEAD top-file.t >actual && | |
40 | echo top-file.t top-file.t top-file.t >expect && | |
41 | test_cmp expect actual | |
42 | ' | |
43 | ||
455923e0 ÆAB |
44 | test_ls_tree_format \ |
45 | "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \ | |
46 | "" | |
47 | ||
48 | test_ls_tree_format \ | |
49 | "%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)" \ | |
50 | "--long" | |
51 | ||
52 | test_ls_tree_format \ | |
53 | "%(path)" \ | |
54 | "--name-only" | |
55 | ||
cab851c2 TL |
56 | test_ls_tree_format \ |
57 | "%(objectname)" \ | |
58 | "--object-only" | |
59 | ||
60 | test_ls_tree_format \ | |
61 | "%(objectname)" \ | |
62 | "--object-only --abbrev" \ | |
63 | "--abbrev" | |
64 | ||
455923e0 ÆAB |
65 | test_ls_tree_format \ |
66 | "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \ | |
67 | "-t" \ | |
68 | "-t" | |
69 | ||
70 | test_ls_tree_format \ | |
71 | "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \ | |
72 | "--full-name" \ | |
73 | "--full-name" | |
74 | ||
75 | test_ls_tree_format \ | |
76 | "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \ | |
77 | "--full-tree" \ | |
78 | "--full-tree" | |
79 | ||
80 | test_done |