interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t3013-ls-files-format.sh

145 lines · 3443 bytes Raw Blame History
1#!/bin/sh
2
3test_description='git ls-files --format test'
4
5. ./test-lib.sh
6
7for flag in -s -o -k -t --resolve-undo --deduplicate --eol
8do
9 test_expect_success "usage: --format is incompatible with $flag" '
10 test_expect_code 129 git ls-files --format="%(objectname)" $flag
11 '
12done
13
14test_expect_success 'setup' '
15 printf "LINEONE\nLINETWO\nLINETHREE\n" >o1.txt &&
16 printf "LINEONE\r\nLINETWO\r\nLINETHREE\r\n" >o2.txt &&
17 printf "LINEONE\r\nLINETWO\nLINETHREE\n" >o3.txt &&
18 git add o?.txt &&
19 oid=$(git hash-object o1.txt) &&
20 git update-index --add --cacheinfo 120000 $oid o4.txt &&
21 git update-index --add --cacheinfo 160000 $oid o5.txt &&
22 git update-index --add --cacheinfo 100755 $oid o6.txt &&
23 git commit -m base
24'
25
26test_expect_success 'git ls-files --format objectmode v.s. -s' '
27 git ls-files -s >files &&
28 cut -d" " -f1 files >expect &&
29 git ls-files --format="%(objectmode)" >actual &&
30 test_cmp expect actual
31'
32
33test_expect_success 'git ls-files --format objectname v.s. -s' '
34 git ls-files -s >files &&
35 cut -d" " -f2 files >expect &&
36 git ls-files --format="%(objectname)" >actual &&
37 test_cmp expect actual
38'
39
40test_expect_success 'git ls-files --format objecttype' '
41 git ls-files --format="%(objectname)" o1.txt o4.txt o6.txt >objectname &&
42 git cat-file --batch-check="%(objecttype)" >expect <objectname &&
43 git ls-files --format="%(objecttype)" o1.txt o4.txt o6.txt >actual &&
44 test_cmp expect actual
45'
46
47test_expect_success 'git ls-files --format objectsize' '
48 cat>expect <<-\EOF &&
4926
5029
5127
5226
53-
5426
55 EOF
56 git ls-files --format="%(objectsize)" >actual &&
57
58 test_cmp expect actual
59'
60
61test_expect_success 'git ls-files --format objectsize:padded' '
62 cat>expect <<-\EOF &&
63 26
64 29
65 27
66 26
67 -
68 26
69 EOF
70 git ls-files --format="%(objectsize:padded)" >actual &&
71
72 test_cmp expect actual
73'
74
75test_expect_success 'git ls-files --format v.s. --eol' '
76 git ls-files --eol >tmp &&
77 sed -e "s/ / /g" -e "s/ */ /g" tmp >expect 2>err &&
78 test_must_be_empty err &&
79 git ls-files --format="i/%(eolinfo:index) w/%(eolinfo:worktree) attr/%(eolattr) %(path)" >actual 2>err &&
80 test_must_be_empty err &&
81 test_cmp expect actual
82'
83
84test_expect_success 'git ls-files --format path v.s. -s' '
85 git ls-files -s >files &&
86 cut -f2 files >expect &&
87 git ls-files --format="%(path)" >actual &&
88 test_cmp expect actual
89'
90
91test_expect_success 'git ls-files --format with relative path' '
92 cat >expect <<-\EOF &&
93 ../o1.txt
94 ../o2.txt
95 ../o3.txt
96 ../o4.txt
97 ../o5.txt
98 ../o6.txt
99 EOF
100 mkdir sub &&
101 cd sub &&
102 git ls-files --format="%(path)" ":/" >../actual &&
103 cd .. &&
104 test_cmp expect actual
105'
106
107test_expect_success 'git ls-files --format with -m' '
108 echo change >o1.txt &&
109 cat >expect <<-\EOF &&
110 o1.txt
111 o4.txt
112 o5.txt
113 o6.txt
114 EOF
115 git ls-files --format="%(path)" -m >actual &&
116 test_cmp expect actual
117'
118
119test_expect_success 'git ls-files --format with -d' '
120 echo o7 >o7.txt &&
121 git add o7.txt &&
122 rm o7.txt &&
123 cat >expect <<-\EOF &&
124 o4.txt
125 o5.txt
126 o6.txt
127 o7.txt
128 EOF
129 git ls-files --format="%(path)" -d >actual &&
130 test_cmp expect actual
131'
132
133test_expect_success 'git ls-files --format v.s -s' '
134 git ls-files --stage >expect &&
135 git ls-files --format="%(objectmode) %(objectname) %(stage)%x09%(path)" >actual &&
136 test_cmp expect actual
137'
138
139test_expect_success 'git ls-files --format with --debug' '
140 git ls-files --debug >expect &&
141 git ls-files --format="%(path)" --debug >actual &&
142 test_cmp expect actual
143'
144
145test_done