3 test_description
='git ls-files --format test'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 for flag
in -s -o -k -t --resolve-undo --deduplicate --eol
10 test_expect_success
"usage: --format is incompatible with $flag" '
11 test_expect_code 129 git ls-files --format="%(objectname)" $flag
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 &&
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 &&
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
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
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
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
57 test_expect_success
'git ls-files --format with relative path' '
58 cat >expect <<-\EOF &&
68 git ls-files --format="%(path)" ":/" >../actual &&
70 test_cmp expect actual
73 test_expect_success
'git ls-files --format with -m' '
74 echo change >o1.txt &&
75 cat >expect <<-\EOF &&
81 git ls-files --format="%(path)" -m >actual &&
82 test_cmp expect actual
85 test_expect_success
'git ls-files --format with -d' '
89 cat >expect <<-\EOF &&
95 git ls-files --format="%(path)" -d >actual &&
96 test_cmp expect actual
99 test_expect_success
'git ls-files --format v.s -s' '
100 git ls-files --stage >expect &&
101 git ls-files --format="%(objectmode) %(objectname) %(stage)%x09%(path)" >actual &&
102 test_cmp expect actual
105 test_expect_success
'git ls-files --format with --debug' '
106 git ls-files --debug >expect &&
107 git ls-files --format="%(path)" --debug >actual &&
108 test_cmp expect actual