3 . "$(dirname "$0")/testlib.sh"
5 begin_test "track files using wildcard pattern with leading slash"
9 reponame="track-wildcard-leading-slash"
10 mkdir -p "$reponame/dir"
15 # Adding files before being tracked by LFS
16 printf "contents" > a.dat
17 printf "contents" > dir/b.dat
19 git add a.dat dir/b.dat
20 git commit -m "initial commit"
22 # Track only in the root
23 git lfs track "/*.dat"
24 grep "/*.dat" .gitattributes
26 git add .gitattributes a.dat dir/b.dat
28 git commit -m "convert to LFS"
30 git lfs ls-files | tee files.log
32 grep "a.dat" files.log
33 [ ! $(grep "dir/b.dat" files.log) ] # Subdirectories ignored
35 # Add files after being tracked by LFS
36 printf "contents" > c.dat
37 printf "contents" > dir/d.dat
39 git add c.dat dir/d.dat
41 git commit -m "more lfs files"
43 git lfs ls-files | tee new_files.log
45 grep "a.dat" new_files.log
46 [ ! $(grep "dir/b.dat" new_files.log) ]
47 grep "c.dat" new_files.log
48 [ ! $(grep "dir/d.dat" new_files.log) ]
52 begin_test "track files using filename pattern with leading slash"
56 reponame="track-absolute-leading-slash"
57 mkdir -p "$reponame/dir"
62 # Adding files before being tracked by LFS
63 printf "contents" > a.dat
64 printf "contents" > dir/b.dat
66 git add a.dat dir/b.dat
68 git commit -m "initial commit"
70 # These are added by git.GetTrackedFiles
71 git lfs track "/a.dat" | tee track.log
72 grep "Tracking \"/a.dat\"" track.log
73 git lfs track "/dir/b.dat" | tee track.log
74 grep "Tracking \"/dir/b.dat\"" track.log
76 # These are added by Git's `clean` filter
77 git lfs track "/c.dat" | tee track.log
78 grep "Tracking \"/c.dat\"" track.log
79 git lfs track "/dir/d.dat" | tee track.log
80 grep "Tracking \"/dir/d.dat\"" track.log
84 git add .gitattributes a.dat dir/b.dat
86 git commit -m "convert to LFS"
88 git lfs ls-files | tee files.log
90 grep "a.dat" files.log
91 grep "dir/b.dat" files.log
93 # Add files after being tracked by LFS
94 printf "contents" > c.dat
95 printf "contents" > dir/d.dat
97 git add c.dat dir/d.dat
98 git commit -m "more lfs files"
100 git lfs ls-files | tee new_files.log
102 grep "a.dat" new_files.log
103 grep "dir/b.dat" new_files.log
104 grep "c.dat" new_files.log
105 grep "dir/d.dat" new_files.log