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 -m' '
58 echo change >o1.txt &&
59 cat >expect <<-\EOF &&
65 git ls-files --format="%(path)" -m >actual &&
66 test_cmp expect actual
69 test_expect_success
'git ls-files --format with -d' '
73 cat >expect <<-\EOF &&
79 git ls-files --format="%(path)" -d >actual &&
80 test_cmp expect actual
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
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