Merge tag 'l10n-2.36.0-rnd2.1' of https://github.com/git-l10n/git-po
[alt-git.git] / t / t3104-ls-tree-format.sh
blob0769a933d695e5525b08a4e39b8cc0f8370eb08b
1 #!/bin/sh
3 test_description='ls-tree --format'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'ls-tree --format usage' '
9 test_expect_code 129 git ls-tree --format=fmt -l HEAD &&
10 test_expect_code 129 git ls-tree --format=fmt --name-only HEAD &&
11 test_expect_code 129 git ls-tree --format=fmt --name-status HEAD
14 test_expect_success 'setup' '
15 mkdir dir &&
16 test_commit dir/sub-file &&
17 test_commit top-file
20 test_ls_tree_format () {
21 format=$1 &&
22 opts=$2 &&
23 fmtopts=$3 &&
24 shift 2 &&
26 test_expect_success "ls-tree '--format=<$format>' is like options '$opts $fmtopts'" '
27 git ls-tree $opts -r HEAD >expect &&
28 git ls-tree --format="$format" -r $fmtopts HEAD >actual &&
29 test_cmp expect actual
32 test_expect_success "ls-tree '--format=<$format>' on optimized v.s. non-optimized path" '
33 git ls-tree --format="$format" -r $fmtopts HEAD >expect &&
34 git ls-tree --format="> $format" -r $fmtopts HEAD >actual.raw &&
35 sed "s/^> //" >actual <actual.raw &&
36 test_cmp expect actual
40 test_ls_tree_format \
41 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
44 test_ls_tree_format \
45 "%(objectmode) %(objecttype) %(objectname) %(objectsize:padded)%x09%(path)" \
46 "--long"
48 test_ls_tree_format \
49 "%(path)" \
50 "--name-only"
52 test_ls_tree_format \
53 "%(objectname)" \
54 "--object-only"
56 test_ls_tree_format \
57 "%(objectname)" \
58 "--object-only --abbrev" \
59 "--abbrev"
61 test_ls_tree_format \
62 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
63 "-t" \
64 "-t"
66 test_ls_tree_format \
67 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
68 "--full-name" \
69 "--full-name"
71 test_ls_tree_format \
72 "%(objectmode) %(objecttype) %(objectname)%x09%(path)" \
73 "--full-tree" \
74 "--full-tree"
76 test_done