builtin/am: allow disabling conflict advice
[alt-git.git] / t / t3105-ls-tree-output.sh
blobce2391e28be6f213aead49ec1315e6f5f08fa25d
1 #!/bin/sh
3 test_description='ls-tree output'
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_mode_output () {
20 local opts="$1" &&
21 shift &&
22 cat >expect &&
24 while test $# -gt 0
26 local mode="$1" &&
27 shift &&
29 test_expect_success "'ls-tree $opts${mode:+ $mode}' output" '
30 git ls-tree ${mode:+$mode }$opts HEAD >actual &&
31 test_cmp expect actual
34 case "$opts" in
35 --full-tree)
36 test_expect_success "'ls-tree $opts${mode:+ $mode}' output (via subdir, fails)" '
37 test_must_fail git -C dir ls-tree --full-name ${mode:+$mode }$opts HEAD -- ../
41 test_expect_success "'ls-tree $opts${mode:+ $mode}' output (via subdir)" '
42 git -C dir ls-tree --full-name ${mode:+$mode }$opts HEAD -- ../ >actual &&
43 test_cmp expect actual
46 esac
47 done
50 # test exact output of option (none, --long, ...) and mode (none and
51 # -d, -r -t) and combinations
52 test_expect_success 'setup: HEAD_* variables' '
53 HEAD_gitmodules=$(git rev-parse HEAD:.gitmodules) &&
54 HEAD_dir=$(git rev-parse HEAD:dir) &&
55 HEAD_top_file=$(git rev-parse HEAD:top-file.t) &&
56 HEAD_submodule=$(git rev-parse HEAD:submodule) &&
57 HEAD_dir_sub_file=$(git rev-parse HEAD:dir/sub-file.t)
59 ## opt =
60 test_ls_tree_format_mode_output "" "" "-t" <<-EOF
61 100644 blob $HEAD_gitmodules .gitmodules
62 040000 tree $HEAD_dir dir
63 160000 commit $HEAD_submodule submodule
64 100644 blob $HEAD_top_file top-file.t
65 EOF
66 test_ls_tree_format_mode_output "" "-d" <<-EOF
67 040000 tree $HEAD_dir dir
68 160000 commit $HEAD_submodule submodule
69 EOF
70 test_ls_tree_format_mode_output "" "-r" <<-EOF
71 100644 blob $HEAD_gitmodules .gitmodules
72 100644 blob $HEAD_dir_sub_file dir/sub-file.t
73 160000 commit $HEAD_submodule submodule
74 100644 blob $HEAD_top_file top-file.t
75 EOF
76 ## opt = --long
77 test_ls_tree_format_mode_output "--long" "" "-t" <<-EOF
78 100644 blob $HEAD_gitmodules 61 .gitmodules
79 040000 tree $HEAD_dir - dir
80 160000 commit $HEAD_submodule - submodule
81 100644 blob $HEAD_top_file 9 top-file.t
82 EOF
83 test_ls_tree_format_mode_output "--long" "-d" <<-EOF
84 040000 tree $HEAD_dir - dir
85 160000 commit $HEAD_submodule - submodule
86 EOF
87 test_ls_tree_format_mode_output "--long" "-r" <<-EOF
88 100644 blob $HEAD_gitmodules 61 .gitmodules
89 100644 blob $HEAD_dir_sub_file 13 dir/sub-file.t
90 160000 commit $HEAD_submodule - submodule
91 100644 blob $HEAD_top_file 9 top-file.t
92 EOF
93 ## opt = --name-only
94 test_ls_tree_format_mode_output "--name-only" "" "-t" <<-EOF
95 .gitmodules
96 dir
97 submodule
98 top-file.t
99 EOF
100 test_ls_tree_format_mode_output "--name-only" "-d" <<-EOF
102 submodule
104 test_ls_tree_format_mode_output "--name-only" "-r" <<-EOF
105 .gitmodules
106 dir/sub-file.t
107 submodule
108 top-file.t
110 ## opt = --object-only
111 test_ls_tree_format_mode_output "--object-only" "" "-t" <<-EOF
112 $HEAD_gitmodules
113 $HEAD_dir
114 $HEAD_submodule
115 $HEAD_top_file
117 test_ls_tree_format_mode_output "--object-only" "-d" <<-EOF
118 $HEAD_dir
119 $HEAD_submodule
121 test_ls_tree_format_mode_output "--object-only" "-r" <<-EOF
122 $HEAD_gitmodules
123 $HEAD_dir_sub_file
124 $HEAD_submodule
125 $HEAD_top_file
127 ## opt = --object-only --abbrev
128 test_expect_success 'setup: HEAD_short_* variables' '
129 HEAD_short_gitmodules=$(git rev-parse --short HEAD:.gitmodules) &&
130 HEAD_short_dir=$(git rev-parse --short HEAD:dir) &&
131 HEAD_short_top_file=$(git rev-parse --short HEAD:top-file.t) &&
132 HEAD_short_submodule=$(git rev-parse --short HEAD:submodule) &&
133 HEAD_short_dir_sub_file=$(git rev-parse --short HEAD:dir/sub-file.t)
135 test_ls_tree_format_mode_output "--object-only --abbrev" "" "-t" <<-EOF
136 $HEAD_short_gitmodules
137 $HEAD_short_dir
138 $HEAD_short_submodule
139 $HEAD_short_top_file
141 test_ls_tree_format_mode_output "--object-only --abbrev" "-d" <<-EOF
142 $HEAD_short_dir
143 $HEAD_short_submodule
145 test_ls_tree_format_mode_output "--object-only --abbrev" "-r" <<-EOF
146 $HEAD_short_gitmodules
147 $HEAD_short_dir_sub_file
148 $HEAD_short_submodule
149 $HEAD_short_top_file
151 ## opt = --full-name
152 test_ls_tree_format_mode_output "--full-name" "" <<-EOF
153 100644 blob $HEAD_gitmodules .gitmodules
154 040000 tree $HEAD_dir dir
155 160000 commit $HEAD_submodule submodule
156 100644 blob $HEAD_top_file top-file.t
158 test_ls_tree_format_mode_output "--full-name" "-d" <<-EOF
159 040000 tree $HEAD_dir dir
160 160000 commit $HEAD_submodule submodule
162 test_ls_tree_format_mode_output "--full-name" "-r" <<-EOF
163 100644 blob $HEAD_gitmodules .gitmodules
164 100644 blob $HEAD_dir_sub_file dir/sub-file.t
165 160000 commit $HEAD_submodule submodule
166 100644 blob $HEAD_top_file top-file.t
168 test_ls_tree_format_mode_output "--full-name" "-t" <<-EOF
169 100644 blob $HEAD_gitmodules .gitmodules
170 040000 tree $HEAD_dir dir
171 160000 commit $HEAD_submodule submodule
172 100644 blob $HEAD_top_file top-file.t
174 ## opt = --full-tree
175 test_ls_tree_format_mode_output "--full-tree" "" "-t" <<-EOF
176 100644 blob $HEAD_gitmodules .gitmodules
177 040000 tree $HEAD_dir dir
178 160000 commit $HEAD_submodule submodule
179 100644 blob $HEAD_top_file top-file.t
181 test_ls_tree_format_mode_output "--full-tree" "-d" <<-EOF
182 040000 tree $HEAD_dir dir
183 160000 commit $HEAD_submodule submodule
185 test_ls_tree_format_mode_output "--full-tree" "-r" <<-EOF
186 100644 blob $HEAD_gitmodules .gitmodules
187 100644 blob $HEAD_dir_sub_file dir/sub-file.t
188 160000 commit $HEAD_submodule submodule
189 100644 blob $HEAD_top_file top-file.t
192 test_done