3 . "$(dirname "$0")/testlib.sh"
9 reponame="$(basename "$0" ".sh")"
10 setup_remote_repo "$reponame"
12 clone_repo "$reponame" clone
13 clone_repo "$reponame" repo
15 git lfs track "*.dat" 2>&1 | tee track.log
16 grep "Tracking \"\*.dat\"" track.log
19 contents_oid=$(calc_oid "$contents")
21 contents2_oid=$(calc_oid "$contents2")
23 contents3_oid=$(calc_oid "$contents3")
26 echo "*.log" > .gitignore
27 printf "$contents" > a.dat
28 printf "$contents2" > á.dat
29 printf "$contents3" > dir/dir.dat
31 git commit -m "add files" 2>&1 | tee commit.log
32 grep "master (root-commit)" commit.log
33 grep "5 files changed" commit.log
34 grep "create mode 100644 a.dat" commit.log
35 grep "create mode 100644 .gitattributes" commit.log
38 [ "a" = "$(cat a.dat)" ]
39 [ "A" = "$(cat "á.dat")" ]
40 [ "dir" = "$(cat "dir/dir.dat")" ]
42 assert_pointer "master" "a.dat" "$contents_oid" 1
43 assert_pointer "master" "á.dat" "$contents2_oid" 1
44 assert_pointer "master" "dir/dir.dat" "$contents3_oid" 3
46 refute_server_object "$reponame" "$contents_oid"
47 refute_server_object "$reponame" "$contents2_oid"
48 refute_server_object "$reponame" "$contents33oid"
51 git push origin master 2>&1 | tee push.log
52 grep "Uploading LFS objects: 100% (3/3), 5 B" push.log
53 grep "master -> master" push.log
55 assert_server_object "$reponame" "$contents_oid"
56 assert_server_object "$reponame" "$contents2_oid"
57 assert_server_object "$reponame" "$contents3_oid"
59 # change to the clone's working directory
65 [ "a" = "$(cat a.dat)" ]
66 [ "A" = "$(cat "á.dat")" ]
68 assert_local_object "$contents_oid" 1
69 assert_local_object "$contents2_oid" 1
73 rm -r a.dat á.dat dir # removing files makes the status dirty
74 rm -rf .git/lfs/objects
75 git lfs pull 2>&1 | grep "Downloading LFS objects: 100% (3/3), 5 B"
77 [ "a" = "$(cat a.dat)" ]
78 [ "A" = "$(cat "á.dat")" ]
79 assert_local_object "$contents_oid" 1
80 assert_local_object "$contents2_oid" 1
82 echo "lfs pull with remote"
84 rm -rf .git/lfs/objects
85 git lfs pull origin 2>&1 | grep "Downloading LFS objects: 100% (3/3), 5 B"
86 [ "a" = "$(cat a.dat)" ]
87 [ "A" = "$(cat "á.dat")" ]
88 assert_local_object "$contents_oid" 1
89 assert_local_object "$contents2_oid" 1
92 echo "lfs pull with local storage"
95 [ "a" = "$(cat a.dat)" ]
96 [ "A" = "$(cat "á.dat")" ]
99 echo "lfs pull with include/exclude filters in gitconfig"
100 rm -rf .git/lfs/objects
101 git config "lfs.fetchinclude" "a*"
103 assert_local_object "$contents_oid" 1
106 rm -rf .git/lfs/objects
107 git config --unset "lfs.fetchinclude"
108 git config "lfs.fetchexclude" "a*"
110 refute_local_object "$contents_oid"
113 echo "lfs pull with include/exclude filters in command line"
114 git config --unset "lfs.fetchexclude"
115 rm -rf .git/lfs/objects
116 git lfs pull --include="a*"
117 assert_local_object "$contents_oid" 1
120 rm -rf .git/lfs/objects
121 git lfs pull --exclude="a*"
122 refute_local_object "$contents_oid"
125 echo "resetting to test status"
129 echo "lfs pull clean status"
133 echo "lfs pull with -I"
134 git lfs pull -I "*.dat"
137 echo "lfs pull in subdir"
142 echo "lfs pull in subdir with -I"
143 git lfs pull -I "*.dat"
148 begin_test "pull without clean filter"
152 GIT_LFS_SKIP_SMUDGE=1 git clone $GITSERVER/t-pull no-clean
155 git config --list > config.txt
156 grep "filter.lfs.clean" config.txt && {
157 echo "clean filter still configured:"
163 contents_oid=$(calc_oid "$contents")
165 # LFS object not downloaded, pointer in working directory
166 grep "$contents_oid" a.dat || {
167 echo "a.dat not $contents_oid"
172 assert_local_object "$contents_oid"
174 git lfs pull | tee pull.txt
175 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
176 echo >&2 "fatal: expected pull to succeed ..."
179 grep "Git LFS is not installed" pull.txt
182 # LFS object downloaded, pointer unchanged
183 grep "$contents_oid" a.dat || {
184 echo "a.dat not $contents_oid"
189 assert_local_object "$contents_oid" 1
193 begin_test "pull with raw remote url"
199 git lfs install --local --skip-smudge
201 git remote add origin $GITSERVER/t-pull
202 git pull origin master
205 contents_oid=$(calc_oid "$contents")
207 # LFS object not downloaded, pointer in working directory
208 refute_local_object "$contents_oid"
209 grep "$contents_oid" a.dat
211 git lfs pull "$GITSERVER/t-pull"
214 # LFS object downloaded and in working directory
215 assert_local_object "$contents_oid" 1
216 [ "0" = "$(grep -c "$contents_oid" a.dat)" ]
217 [ "a" = "$(cat a.dat)" ]
221 begin_test "pull with multiple remotes"
227 git lfs install --local --skip-smudge
229 git remote add origin "$GITSERVER/t-pull"
230 git remote add bad-remote "invalid-url"
231 git pull origin master
234 contents_oid=$(calc_oid "$contents")
236 # LFS object not downloaded, pointer in working directory
237 refute_local_object "$contents_oid"
238 grep "$contents_oid" a.dat
240 # pull should default to origin instead of bad-remote
244 # LFS object downloaded and in working directory
245 assert_local_object "$contents_oid" 1
246 [ "0" = "$(grep -c "$contents_oid" a.dat)" ]
247 [ "a" = "$(cat a.dat)" ]
251 begin_test "pull: with missing object"
255 # this clone is setup in the first test in this file
257 rm -rf .git/lfs/objects
259 contents_oid=$(calc_oid "a")
260 reponame="$(basename "$0" ".sh")"
261 delete_server_object "$reponame" "$contents_oid"
262 refute_server_object "$reponame" "$contents_oid"
264 # should return non-zero, but should also download all the other valid files too
265 git lfs pull 2>&1 | tee pull.log
266 pull_exit="${PIPESTATUS[0]}"
267 [ "$pull_exit" != "0" ]
269 grep "$contents_oid" pull.log
271 contents2_oid=$(calc_oid "A")
272 assert_local_object "$contents2_oid" 1
273 refute_local_object "$contents_oid"
277 begin_test "pull: outside git repository"
280 git lfs pull 2>&1 > pull.log
284 if [ "$res" = "0" ]; then
285 echo "Passes because $GIT_LFS_TEST_DIR is unset."
289 grep "Not in a git repository" pull.log