Merge branch 'rs/clarify-error-in-write-loose-object'
[alt-git.git] / t / t3104-ls-tree-format.sh
blob383896667b6dc9e446c157370dedd3a3aa8051d1
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_ls_tree_format \
40 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
43 test_ls_tree_format \
44 "%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)" \
45 "--long"
47 test_ls_tree_format \
48 "%(path)" \
49 "--name-only"
51 test_ls_tree_format \
52 "%(objectname)" \
53 "--object-only"
55 test_ls_tree_format \
56 "%(objectname)" \
57 "--object-only --abbrev" \
58 "--abbrev"
60 test_ls_tree_format \
61 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
62 "-t" \
63 "-t"
65 test_ls_tree_format \
66 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
67 "--full-name" \
68 "--full-name"
70 test_ls_tree_format \
71 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
72 "--full-tree" \
73 "--full-tree"
75 test_done