]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3013-ls-files-format.sh
Merge branch 'jk/clone-allow-bare-and-o-together'
[thirdparty/git.git] / t / t3013-ls-files-format.sh
1 #!/bin/sh
2
3 test_description='git ls-files --format test'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 for flag in -s -o -k -t --resolve-undo --deduplicate --eol
9 do
10 test_expect_success "usage: --format is incompatible with $flag" '
11 test_expect_code 129 git ls-files --format="%(objectname)" $flag
12 '
13 done
14
15 test_expect_success 'setup' '
16 printf "LINEONE\nLINETWO\nLINETHREE\n" >o1.txt &&
17 printf "LINEONE\r\nLINETWO\r\nLINETHREE\r\n" >o2.txt &&
18 printf "LINEONE\r\nLINETWO\nLINETHREE\n" >o3.txt &&
19 git add o?.txt &&
20 oid=$(git hash-object o1.txt) &&
21 git update-index --add --cacheinfo 120000 $oid o4.txt &&
22 git update-index --add --cacheinfo 160000 $oid o5.txt &&
23 git update-index --add --cacheinfo 100755 $oid o6.txt &&
24 git commit -m base
25 '
26
27 test_expect_success 'git ls-files --format objectmode v.s. -s' '
28 git ls-files -s >files &&
29 cut -d" " -f1 files >expect &&
30 git ls-files --format="%(objectmode)" >actual &&
31 test_cmp expect actual
32 '
33
34 test_expect_success 'git ls-files --format objectname v.s. -s' '
35 git ls-files -s >files &&
36 cut -d" " -f2 files >expect &&
37 git ls-files --format="%(objectname)" >actual &&
38 test_cmp expect actual
39 '
40
41 test_expect_success 'git ls-files --format v.s. --eol' '
42 git ls-files --eol >tmp &&
43 sed -e "s/ / /g" -e "s/ */ /g" tmp >expect 2>err &&
44 test_must_be_empty err &&
45 git ls-files --format="i/%(eolinfo:index) w/%(eolinfo:worktree) attr/%(eolattr) %(path)" >actual 2>err &&
46 test_must_be_empty err &&
47 test_cmp expect actual
48 '
49
50 test_expect_success 'git ls-files --format path v.s. -s' '
51 git ls-files -s >files &&
52 cut -f2 files >expect &&
53 git ls-files --format="%(path)" >actual &&
54 test_cmp expect actual
55 '
56
57 test_expect_success 'git ls-files --format with -m' '
58 echo change >o1.txt &&
59 cat >expect <<-\EOF &&
60 o1.txt
61 o4.txt
62 o5.txt
63 o6.txt
64 EOF
65 git ls-files --format="%(path)" -m >actual &&
66 test_cmp expect actual
67 '
68
69 test_expect_success 'git ls-files --format with -d' '
70 echo o7 >o7.txt &&
71 git add o7.txt &&
72 rm o7.txt &&
73 cat >expect <<-\EOF &&
74 o4.txt
75 o5.txt
76 o6.txt
77 o7.txt
78 EOF
79 git ls-files --format="%(path)" -d >actual &&
80 test_cmp expect actual
81 '
82
83 test_expect_success 'git ls-files --format v.s -s' '
84 git ls-files --stage >expect &&
85 git ls-files --format="%(objectmode) %(objectname) %(stage)%x09%(path)" >actual &&
86 test_cmp expect actual
87 '
88
89 test_expect_success 'git ls-files --format with --debug' '
90 git ls-files --debug >expect &&
91 git ls-files --format="%(path)" --debug >actual &&
92 test_cmp expect actual
93 '
94
95 test_done