Merge branch 'ps/reflog-list' into HEAD
[alt-git.git] / t / t3104-ls-tree-format.sh
blob3adb206a93bc58aac509a1f093f9dd86cb98e5be
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 &&
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
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
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
44 test_ls_tree_format \
45 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
48 test_ls_tree_format \
49 "%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)" \
50 "--long"
52 test_ls_tree_format \
53 "%(path)" \
54 "--name-only"
56 test_ls_tree_format \
57 "%(objectname)" \
58 "--object-only"
60 test_ls_tree_format \
61 "%(objectname)" \
62 "--object-only --abbrev" \
63 "--abbrev"
65 test_ls_tree_format \
66 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
67 "-t" \
68 "-t"
70 test_ls_tree_format \
71 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
72 "--full-name" \
73 "--full-name"
75 test_ls_tree_format \
76 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
77 "--full-tree" \
78 "--full-tree"
80 test_done