3 . "$(dirname "$0")/testlib.sh"
9 reponame="$(basename "$0" ".sh")"
10 setup_remote_repo "$reponame"
12 clone_repo "$reponame" repo
14 git lfs track "*.dat" 2>&1 | tee track.log
15 grep "Tracking \"\*.dat\"" track.log
17 contents="something something"
19 contents_oid=$(calc_oid "$contents")
21 # Same content everywhere is ok, just one object in lfs db
22 printf "$contents" > file1.dat
23 printf "$contents" > file2.dat
24 printf "$contents" > file3.dat
26 printf "$contents" > folder1/nested.dat
27 printf "$contents" > folder2/nested.dat
28 git add file1.dat file2.dat file3.dat folder1/nested.dat folder2/nested.dat
29 git add .gitattributes
30 git commit -m "add files"
32 [ "$contents" = "$(cat file1.dat)" ]
33 [ "$contents" = "$(cat file2.dat)" ]
34 [ "$contents" = "$(cat file3.dat)" ]
35 [ "$contents" = "$(cat folder1/nested.dat)" ]
36 [ "$contents" = "$(cat folder2/nested.dat)" ]
38 assert_pointer "master" "file1.dat" "$contents_oid" $contentsize
40 # Remove the working directory
41 rm -rf file1.dat file2.dat file3.dat folder1/nested.dat folder2/nested.dat
43 echo "checkout should replace all"
44 git lfs checkout 2>&1 | tee checkout.log
45 [ "$contents" = "$(cat file1.dat)" ]
46 [ "$contents" = "$(cat file2.dat)" ]
47 [ "$contents" = "$(cat file3.dat)" ]
48 [ "$contents" = "$(cat folder1/nested.dat)" ]
49 [ "$contents" = "$(cat folder2/nested.dat)" ]
50 grep "Checking out LFS objects: 100% (5/5), 95 B" checkout.log
52 # Remove the working directory
53 rm -rf file1.dat file2.dat file3.dat folder1/nested.dat folder2/nested.dat
55 echo "checkout with filters"
56 git lfs checkout file2.dat
57 [ "$contents" = "$(cat file2.dat)" ]
60 [ ! -f folder1/nested.dat ]
61 [ ! -f folder2/nested.dat ]
63 echo "quotes to avoid shell globbing"
64 git lfs checkout "file*.dat"
65 [ "$contents" = "$(cat file1.dat)" ]
66 [ "$contents" = "$(cat file3.dat)" ]
67 [ ! -f folder1/nested.dat ]
68 [ ! -f folder2/nested.dat ]
70 echo "test subdir context"
72 git lfs checkout nested.dat
73 [ "$contents" = "$(cat nested.dat)" ]
74 [ ! -f ../folder2/nested.dat ]
75 # test '.' in current dir
77 git lfs checkout . 2>&1 | tee checkout.log
78 [ "$contents" = "$(cat nested.dat)" ]
81 echo "test folder param"
82 git lfs checkout folder2
83 [ "$contents" = "$(cat folder2/nested.dat)" ]
85 echo "test '.' in current dir"
86 rm -rf file1.dat file2.dat file3.dat folder1/nested.dat folder2/nested.dat
88 [ "$contents" = "$(cat file1.dat)" ]
89 [ "$contents" = "$(cat file2.dat)" ]
90 [ "$contents" = "$(cat file3.dat)" ]
91 [ "$contents" = "$(cat folder1/nested.dat)" ]
92 [ "$contents" = "$(cat folder2/nested.dat)" ]
94 echo "test checkout with missing data doesn't fail"
95 git push origin master
96 rm -rf .git/lfs/objects
99 [ "$(pointer $contents_oid $contentsize)" = "$(cat file1.dat)" ]
100 [ "$(pointer $contents_oid $contentsize)" = "$(cat file2.dat)" ]
101 [ "$(pointer $contents_oid $contentsize)" = "$(cat file3.dat)" ]
102 [ "$contents" = "$(cat folder1/nested.dat)" ]
103 [ "$contents" = "$(cat folder2/nested.dat)" ]
107 begin_test "checkout: without clean filter"
111 reponame="$(basename "$0" ".sh")"
114 git clone "$GITSERVER/$reponame" checkout-without-clean
115 cd checkout-without-clean
117 echo "checkout without clean filter"
119 git config --list > config.txt
120 grep "filter.lfs.clean" config.txt && {
121 echo "clean filter still configured:"
127 git lfs checkout | tee checkout.txt
128 grep "Git LFS is not installed" checkout.txt
129 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
130 echo >&2 "fatal: expected checkout to succeed ..."
135 contents_oid=$(calc_oid "something something")
136 [ "$(pointer $contents_oid $contentsize)" = "$(cat file1.dat)" ]
137 [ "$(pointer $contents_oid $contentsize)" = "$(cat file2.dat)" ]
138 [ "$(pointer $contents_oid $contentsize)" = "$(cat file3.dat)" ]
139 [ "$(pointer $contents_oid $contentsize)" = "$(cat folder1/nested.dat)" ]
140 [ "$(pointer $contents_oid $contentsize)" = "$(cat folder2/nested.dat)" ]
144 begin_test "checkout: outside git repository"
147 git lfs checkout 2>&1 > checkout.log
151 if [ "$res" = "0" ]; then
152 echo "Passes because $GIT_LFS_TEST_DIR is unset."
156 grep "Not in a git repository" checkout.log
160 begin_test "checkout: write-only file"
164 reponame="checkout-locked"
167 setup_remote_repo_with_file "$reponame" "$filename"
169 pushd "$TRASHDIR" > /dev/null
170 GIT_LFS_SKIP_SMUDGE=1 clone_repo "$reponame" "${reponame}_checkout"
174 refute_file_writeable "$filename"
175 assert_pointer "refs/heads/master" "$filename" "$(calc_oid "$filename\n")" 6
178 git lfs checkout "$filename"
180 refute_file_writeable "$filename"
181 [ "$filename" = "$(cat "$filename")" ]