clone_submodule: avoid using `access()` on directories
[git.git] / t / t3104-ls-tree-format.sh
blob805b30f403e72c3856fe7dd51c033c143e9b7151
1 #!/bin/sh
3 test_description='ls-tree --format'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-t3100.sh
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
15 test_expect_success 'setup' '
16 setup_basic_ls_tree_data
19 test_ls_tree_format () {
20 format=$1 &&
21 opts=$2 &&
22 fmtopts=$3 &&
23 shift 2 &&
25 test_expect_success "ls-tree '--format=<$format>' is like options '$opts $fmtopts'" '
26 git ls-tree $opts -r HEAD >expect &&
27 git ls-tree --format="$format" -r $fmtopts HEAD >actual &&
28 test_cmp expect actual
31 test_expect_success "ls-tree '--format=<$format>' on optimized v.s. non-optimized path" '
32 git ls-tree --format="$format" -r $fmtopts HEAD >expect &&
33 git ls-tree --format="> $format" -r $fmtopts HEAD >actual.raw &&
34 sed "s/^> //" >actual <actual.raw &&
35 test_cmp expect actual
39 test_expect_success "ls-tree --format='%(path) %(path) %(path)' HEAD top-file" '
40 git ls-tree --format="%(path) %(path) %(path)" HEAD top-file.t >actual &&
41 echo top-file.t top-file.t top-file.t >expect &&
42 test_cmp expect actual
45 test_ls_tree_format \
46 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
49 test_ls_tree_format \
50 "%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)" \
51 "--long"
53 test_ls_tree_format \
54 "%(path)" \
55 "--name-only"
57 test_ls_tree_format \
58 "%(objectname)" \
59 "--object-only"
61 test_ls_tree_format \
62 "%(objectname)" \
63 "--object-only --abbrev" \
64 "--abbrev"
66 test_ls_tree_format \
67 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
68 "-t" \
69 "-t"
71 test_ls_tree_format \
72 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
73 "--full-name" \
74 "--full-name"
76 test_ls_tree_format \
77 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
78 "--full-tree" \
79 "--full-tree"
81 test_done