12 git lfs track "*.dat" | grep "Tracking \"\*.dat\""
13 echo "some data" > some.dat
14 echo "some text" > some.txt
15 echo "missing" > missing.dat
17 git commit -m "add missing file"
18 [ "6bbd052ab0 * missing.dat" = "$(git lfs ls-files)" ]
21 git add some.dat some.txt
22 git commit -m "added some files, removed missing one"
24 git lfs ls-files | tee ls.log
26 [ `wc -l < ls.log` = 1 ]
28 diff -u <(git lfs ls-files --debug) <(cat <<-EOF
33 oid: sha256 5aa03f96c77536579166fba147929626cc3a97960e994057a9d80271a736d10f
34 version: https://git-lfs.github.com/spec/v1
40 begin_test "ls-files: --size"
44 reponame="ls-files-size"
49 git add .gitattributes
50 git commit -m "initial commit"
53 size="$(printf "$contents" | wc -c | awk '{ print $1 }')"
54 printf "$contents" > a.dat
57 git commit -m "add a.dat"
59 git lfs ls-files --size 2>&1 | tee ls.log
60 [ "d1b2a59fbe * a.dat (8 B)" = "$(cat ls.log)" ]
64 begin_test "ls-files: indexed files without tree"
68 reponame="ls-files-indexed-files-without-tree"
73 git add .gitattributes
76 oid="$(calc_oid "$contents")"
77 printf "$contents" > a.dat
79 [ "" = "$(git lfs ls-files)" ]
83 [ "${oid:0:10} * a.dat" = "$(git lfs ls-files)" ]
87 begin_test "ls-files: indexed file with tree"
91 reponame="ls-files-indexed-files-with-tree"
96 git add .gitattributes
97 git commit -m "initial commit"
100 tree_oid="$(calc_oid "$tree_contents")"
102 printf "$tree_contents" > a.dat
104 git commit -m "add a.dat"
107 index_oid="$(calc_oid "$index_contents")"
109 printf "$index_contents" > a.dat
112 [ "${index_oid:0:10} * a.dat" = "$(git lfs ls-files)" ]
116 begin_test "ls-files: outside git repository"
119 git lfs ls-files 2>&1 > ls-files.log
123 if [ "$res" = "0" ]; then
124 echo "Passes because $GIT_LFS_TEST_DIR is unset."
128 grep "Not in a git repository" ls-files.log
132 begin_test "ls-files: --include"
136 git init ls-files-include
139 git lfs track "*.dat" "*.bin"
144 git add *.gitattributes a.dat b.dat c.bin
145 git commit -m "initial commit"
147 git lfs ls-files --include="*.dat" 2>&1 | tee ls-files.log
149 [ "0" -eq "$(grep -c "\.bin" ls-files.log)" ]
150 [ "2" -eq "$(grep -c "\.dat" ls-files.log)" ]
154 begin_test "ls-files: --exclude"
158 git init ls-files-exclude
163 git lfs track "*.dat"
168 git add *.gitattributes a.dat b.dat dir/c.dat
169 git commit -m "initial commit"
171 git lfs ls-files --exclude="dir/" 2>&1 | tee ls-files.log
173 [ "0" -eq "$(grep -c "dir" ls-files.log)" ]
174 [ "2" -eq "$(grep -c "\.dat" ls-files.log)" ]
178 begin_test "ls-files: before first commit"
182 reponame="ls-files-before-first-commit"
186 if [ 0 -ne $(git lfs ls-files | wc -l) ]; then
187 echo >&2 "fatal: expected \`git lfs ls-files\` to produce no output"
193 begin_test "ls-files: show duplicate files"
201 git lfs track "*.tgz" | grep "Tracking \"\*.tgz\""
202 echo "test content" > one.tgz
203 echo "test content" > two.tgz
206 git commit -m "add duplicate files"
208 expected="$(echo "a1fff0ffef * one.tgz
209 a1fff0ffef * two.tgz")"
211 [ "$expected" = "$(git lfs ls-files)" ]
215 begin_test "ls-files: show duplicate files with long OID"
223 git lfs track "*.tgz" | grep "Tracking \"\*.tgz\""
224 echo "test content" > one.tgz
225 echo "test content" > two.tgz
228 git commit -m "add duplicate files with long OID"
230 expected="$(echo "a1fff0ffefb9eace7230c24e50731f0a91c62f9cefdfe77121c2f607125dffae * one.tgz
231 a1fff0ffefb9eace7230c24e50731f0a91c62f9cefdfe77121c2f607125dffae * two.tgz")"
233 [ "$expected" = "$(git lfs ls-files --long)" ]
237 begin_test "ls-files: history with --all"
241 reponame="ls-files-history-with-all"
245 git lfs track '*.dat'
249 git add .gitattributes a.dat b.dat
250 git commit -m "initial commit"
254 git commit -m "remove b.dat"
256 git lfs ls-files 2>&1 | tee ls-files.log
257 [ 1 -eq $(grep -c "a\.dat" ls-files.log) ]
258 [ 0 -eq $(grep -c "b\.dat" ls-files.log) ]
260 git lfs ls-files --all 2>&1 | tee ls-files-all.log
261 [ 1 -eq $(grep -c "a\.dat" ls-files-all.log) ]
262 [ 1 -eq $(grep -c "b\.dat" ls-files-all.log) ]
266 begin_test "ls-files: --all with argument(s)"
270 reponame="ls-files-all-with-arguments"
274 git lfs ls-files --all master 2>&1 | tee ls-files.log
276 if [ "0" -eq "${PIPESTATUS[0]}" ]; then
277 echo >&2 "fatal: \`git lfs ls-files --all master\` to fail"
281 [ "fatal: cannot use --all with explicit reference" = "$(cat ls-files.log)" ]
285 begin_test "ls-files: reference with --deleted"
289 reponame="ls-files-reference-with-deleted"
293 git lfs track "*.dat"
295 git add .gitattributes a.dat
296 git commit -m "initial commit"
300 git commit -m "a.dat: remove a.dat"
302 git lfs ls-files 2>&1 | tee ls-files.log
303 git lfs ls-files --deleted 2>&1 | tee ls-files-deleted.log
305 [ 0 -eq $(grep -c "a\.dat" ls-files.log) ]
306 [ 1 -eq $(grep -c "a\.dat" ls-files-deleted.log) ]