5 begin_test "push with good ref"
8 reponame="push-master-branch-required"
9 setup_remote_repo "$reponame"
10 clone_repo "$reponame" "$reponame"
12 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" false
15 git add .gitattributes a.dat
16 git commit -m "add a.dat"
18 git lfs push origin master
22 begin_test "push with tracked ref"
25 reponame="push-tracked-branch-required"
26 setup_remote_repo "$reponame"
27 clone_repo "$reponame" "$reponame"
29 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" false
32 git add .gitattributes a.dat
33 git commit -m "add a.dat"
35 git config push.default upstream
36 git config branch.master.merge refs/heads/tracked
37 git lfs push origin master
41 begin_test "push with bad ref"
44 reponame="push-other-branch-required"
45 setup_remote_repo "$reponame"
46 clone_repo "$reponame" "$reponame"
48 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" false
51 git add .gitattributes a.dat
52 git commit -m "add a.dat"
54 git lfs push origin master 2>&1 | tee push.log
55 if [ "0" -eq "${PIPESTATUS[0]}" ]; then
56 echo "expected command to fail"
60 grep 'batch response: Expected ref "refs/heads/other", got "refs/heads/master"' push.log
68 reponame="$(basename "$0" ".sh")"
69 setup_remote_repo "$reponame"
70 clone_repo "$reponame" repo
72 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" true
76 git add .gitattributes a.dat
77 git commit -m "add a.dat"
79 git lfs push --dry-run origin master 2>&1 | tee push.log
80 grep "push 4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 => a.dat" push.log
81 [ $(grep -c "push" push.log) -eq 1 ]
83 git lfs push origin master 2>&1 | tee push.log
84 grep "Uploading LFS objects: 100% (1/1), 7 B" push.log
86 git checkout -b push-b
89 git commit -m "add b.dat"
91 git lfs push --dry-run origin push-b 2>&1 | tee push.log
92 grep "push 4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 => a.dat" push.log
93 grep "push 82be50ad35070a4ef3467a0a650c52d5b637035e7ad02c36652e59d01ba282b7 => b.dat" push.log
94 [ $(grep -c "push" < push.log) -eq 2 ]
97 mkdir -p .git/refs/remotes/origin
98 git rev-parse HEAD > .git/refs/remotes/origin/HEAD
100 git lfs push --dry-run origin push-b 2>&1 | tee push.log
101 [ $(grep -c "push" push.log) -eq 0 ]
103 rm -rf .git/refs/remotes
105 git lfs push origin push-b 2>&1 | tee push.log
106 grep "Uploading LFS objects: 100% (2/2), 14 B" push.log
110 # sets up the tests for the next few push --all tests
113 reponame="$(basename "$0" ".sh")-all"
120 oid1=$(calc_oid "$content1")
121 oid2=$(calc_oid "$content2")
122 oid3=$(calc_oid "$content3")
123 oid4=$(calc_oid "$content4")
124 oid5=$(calc_oid "$content5")
125 extraoid=$(calc_oid "$extracontent")
127 # if the local repo exists, it has already been bootstrapped
128 [ -d "push-all" ] && exit 0
130 clone_repo "$reponame" "push-all"
131 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" true
132 git lfs track "*.dat"
136 \"CommitDate\":\"$(get_date -6m)\",
138 {\"Filename\":\"file1.dat\",\"Size\":${#content1},\"Data\":\"$content1\"}
142 \"CommitDate\":\"$(get_date -5m)\",
144 {\"Filename\":\"file1.dat\",\"Size\":${#content2},\"Data\":\"$content2\"}
148 \"CommitDate\":\"$(get_date -4m)\",
149 \"NewBranch\":\"branch\",
151 {\"Filename\":\"file1.dat\",\"Size\":${#content3},\"Data\":\"$content3\"}
155 \"CommitDate\":\"$(get_date -4m)\",
156 \"ParentBranches\":[\"master\"],
159 {\"Filename\":\"file1.dat\",\"Size\":${#content4},\"Data\":\"$content4\"}
163 \"CommitDate\":\"$(get_date -2m)\",
165 {\"Filename\":\"file1.dat\",\"Size\":${#content5},\"Data\":\"$content5\"},
166 {\"Filename\":\"file2.dat\",\"Size\":${#extracontent},\"Data\":\"$extracontent\"}
169 ]" | lfstest-testutils addcommits
172 git commit -m "remove file2.dat"
174 # simulate remote ref
175 mkdir -p .git/refs/remotes/origin
176 git rev-parse HEAD > .git/refs/remotes/origin/HEAD
178 setup_alternate_remote "$reponame-$suffix"
179 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix").locksverify" true
182 begin_test "push --all (no ref args)"
186 push_all_setup "everything"
188 git lfs push --dry-run --all origin 2>&1 | tee push.log
189 grep "push $oid1 => file1.dat" push.log
190 grep "push $oid2 => file1.dat" push.log
191 grep "push $oid3 => file1.dat" push.log
192 grep "push $oid4 => file1.dat" push.log
193 grep "push $oid5 => file1.dat" push.log
194 grep "push $extraoid => file2.dat" push.log
195 [ $(grep -c "push" < push.log) -eq 6 ]
197 git push --all origin 2>&1 | tee push.log
198 [ $(grep -c "Uploading LFS objects: 100% (6/6), 36 B" push.log) -eq 1 ]
199 assert_server_object "$reponame-$suffix" "$oid1"
200 assert_server_object "$reponame-$suffix" "$oid2"
201 assert_server_object "$reponame-$suffix" "$oid3"
202 assert_server_object "$reponame-$suffix" "$oid4"
203 assert_server_object "$reponame-$suffix" "$oid5"
204 assert_server_object "$reponame-$suffix" "$extraoid"
206 echo "push while missing old objects locally"
207 setup_alternate_remote "$reponame-$suffix-2"
208 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
210 git lfs push --object-id origin $oid1
211 assert_server_object "$reponame-$suffix-2" "$oid1"
212 refute_server_object "$reponame-$suffix-2" "$oid2"
213 refute_server_object "$reponame-$suffix-2" "$oid3"
214 refute_server_object "$reponame-$suffix-2" "$oid4"
215 refute_server_object "$reponame-$suffix-2" "$oid5"
216 refute_server_object "$reponame-$suffix-2" "$extraoid"
217 rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
219 echo "dry run missing local object that exists on server"
220 git lfs push --dry-run --all origin 2>&1 | tee push.log
221 grep "push $oid1 => file1.dat" push.log
222 grep "push $oid2 => file1.dat" push.log
223 grep "push $oid3 => file1.dat" push.log
224 grep "push $oid4 => file1.dat" push.log
225 grep "push $oid5 => file1.dat" push.log
226 grep "push $extraoid => file2.dat" push.log
227 [ $(grep -c "push" push.log) -eq 6 ]
229 git push --all origin 2>&1 | tee push.log
230 grep "Uploading LFS objects: 100% (6/6), 36 B" push.log
231 assert_server_object "$reponame-$suffix-2" "$oid2"
232 assert_server_object "$reponame-$suffix-2" "$oid3"
233 assert_server_object "$reponame-$suffix-2" "$oid4"
234 assert_server_object "$reponame-$suffix-2" "$oid5"
235 assert_server_object "$reponame-$suffix-2" "$extraoid"
239 begin_test "push --all (1 ref arg)"
245 git lfs push --dry-run --all origin branch 2>&1 | tee push.log
246 grep "push $oid1 => file1.dat" push.log
247 grep "push $oid2 => file1.dat" push.log
248 grep "push $oid3 => file1.dat" push.log
249 [ $(grep -c "push" < push.log) -eq 3 ]
251 git lfs push --all origin branch 2>&1 | tee push.log
252 grep "3 files" push.log
253 assert_server_object "$reponame-$suffix" "$oid1"
254 assert_server_object "$reponame-$suffix" "$oid2"
255 assert_server_object "$reponame-$suffix" "$oid3"
256 refute_server_object "$reponame-$suffix" "$oid4" # in master and the tag
257 refute_server_object "$reponame-$suffix" "$oid5"
258 refute_server_object "$reponame-$suffix" "$extraoid"
260 echo "push while missing old objects locally"
261 setup_alternate_remote "$reponame-$suffix-2"
262 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
263 git lfs push --object-id origin $oid1
264 assert_server_object "$reponame-$suffix-2" "$oid1"
265 refute_server_object "$reponame-$suffix-2" "$oid2"
266 refute_server_object "$reponame-$suffix-2" "$oid3"
267 refute_server_object "$reponame-$suffix-2" "$oid4"
268 refute_server_object "$reponame-$suffix-2" "$oid5"
269 refute_server_object "$reponame-$suffix-2" "$extraoid"
270 rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
272 # dry run doesn't change
273 git lfs push --dry-run --all origin branch 2>&1 | tee push.log
274 grep "push $oid1 => file1.dat" push.log
275 grep "push $oid2 => file1.dat" push.log
276 grep "push $oid3 => file1.dat" push.log
277 [ $(grep -c "push" push.log) -eq 3 ]
279 git push --all origin branch 2>&1 | tee push.log
280 grep "5 files, 1 skipped" push.log # should be 5?
281 assert_server_object "$reponame-$suffix-2" "$oid2"
282 assert_server_object "$reponame-$suffix-2" "$oid3"
283 refute_server_object "$reponame-$suffix-2" "$oid4"
284 refute_server_object "$reponame-$suffix-2" "$oid5"
285 refute_server_object "$reponame-$suffix-2" "$extraoid"
289 begin_test "push --all (multiple ref args)"
293 push_all_setup "multiple-refs"
295 git lfs push --dry-run --all origin branch tag 2>&1 | tee push.log
296 grep "push $oid1 => file1.dat" push.log
297 grep "push $oid2 => file1.dat" push.log
298 grep "push $oid3 => file1.dat" push.log
299 grep "push $oid4 => file1.dat" push.log
300 [ $(grep -c "push" push.log) -eq 4 ]
302 git lfs push --all origin branch tag 2>&1 | tee push.log
303 grep "4 files" push.log
304 assert_server_object "$reponame-$suffix" "$oid1"
305 assert_server_object "$reponame-$suffix" "$oid2"
306 assert_server_object "$reponame-$suffix" "$oid3"
307 assert_server_object "$reponame-$suffix" "$oid4"
308 refute_server_object "$reponame-$suffix" "$oid5" # only in master
309 refute_server_object "$reponame-$suffix" "$extraoid"
311 echo "push while missing old objects locally"
312 setup_alternate_remote "$reponame-$suffix-2"
313 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
314 git lfs push --object-id origin $oid1
315 assert_server_object "$reponame-$suffix-2" "$oid1"
316 refute_server_object "$reponame-$suffix-2" "$oid2"
317 refute_server_object "$reponame-$suffix-2" "$oid3"
318 refute_server_object "$reponame-$suffix-2" "$oid4"
319 refute_server_object "$reponame-$suffix-2" "$oid5"
320 refute_server_object "$reponame-$suffix-2" "$extraoid"
321 rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
323 # dry run doesn't change
324 git lfs push --dry-run --all origin branch tag 2>&1 | tee push.log
325 grep "push $oid1 => file1.dat" push.log
326 grep "push $oid2 => file1.dat" push.log
327 grep "push $oid3 => file1.dat" push.log
328 grep "push $oid4 => file1.dat" push.log
329 [ $(grep -c "push" push.log) -eq 3 ]
331 git push --all origin branch tag 2>&1 | tee push.log
332 grep "5 files, 1 skipped" push.log # should be 5?
333 assert_server_object "$reponame-$suffix-2" "$oid2"
334 assert_server_object "$reponame-$suffix-2" "$oid3"
335 assert_server_object "$reponame-$suffix-2" "$oid4"
336 refute_server_object "$reponame-$suffix-2" "$oid5"
337 refute_server_object "$reponame-$suffix-2" "$extraoid"
341 begin_test "push --all (ref with deleted files)"
345 push_all_setup "ref-with-deleted"
347 git lfs push --dry-run --all origin master 2>&1 | tee push.log
348 grep "push $oid1 => file1.dat" push.log
349 grep "push $oid2 => file1.dat" push.log
350 grep "push $oid4 => file1.dat" push.log
351 grep "push $oid5 => file1.dat" push.log
352 grep "push $extraoid => file2.dat" push.log
353 [ $(grep -c "push" push.log) -eq 5 ]
355 git lfs push --all origin master 2>&1 | tee push.log
356 grep "5 files" push.log
357 assert_server_object "$reponame-$suffix" "$oid1"
358 assert_server_object "$reponame-$suffix" "$oid2"
359 refute_server_object "$reponame-$suffix" "$oid3" # only in the branch
360 assert_server_object "$reponame-$suffix" "$oid4"
361 assert_server_object "$reponame-$suffix" "$oid5"
362 assert_server_object "$reponame-$suffix" "$extraoid"
364 echo "push while missing old objects locally"
365 setup_alternate_remote "$reponame-$suffix-2"
366 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame-$suffix-2").locksverify" true
367 git lfs push --object-id origin $oid1
368 assert_server_object "$reponame-$suffix-2" "$oid1"
369 refute_server_object "$reponame-$suffix-2" "$oid2"
370 refute_server_object "$reponame-$suffix-2" "$oid3"
371 refute_server_object "$reponame-$suffix-2" "$oid4"
372 refute_server_object "$reponame-$suffix-2" "$oid5"
373 refute_server_object "$reponame-$suffix-2" "$extraoid"
374 rm ".git/lfs/objects/${oid1:0:2}/${oid1:2:2}/$oid1"
376 # dry run doesn't change
377 git lfs push --dry-run --all origin master 2>&1 | tee push.log
378 grep "push $oid1 => file1.dat" push.log
379 grep "push $oid2 => file1.dat" push.log
380 grep "push $oid4 => file1.dat" push.log
381 grep "push $oid5 => file1.dat" push.log
382 grep "push $extraoid => file2.dat" push.log
383 [ $(grep -c "push" push.log) -eq 5 ]
385 git push --all origin master 2>&1 | tee push.log
386 grep "5 files, 1 skipped" push.log # should be 5?
387 assert_server_object "$reponame-$suffix-2" "$oid2"
388 refute_server_object "$reponame-$suffix-2" "$oid3"
389 assert_server_object "$reponame-$suffix-2" "$oid4"
390 assert_server_object "$reponame-$suffix-2" "$oid5"
391 assert_server_object "$reponame-$suffix-2" "$extraoid"
395 begin_test "push object id(s)"
399 reponame="$(basename "$0" ".sh")"
400 setup_remote_repo "$reponame"
401 clone_repo "$reponame" repo2
403 git config "lfs.$(repo_endpoint "$GITSERVER" "$reponame").locksverify" true
405 git lfs track "*.dat"
406 echo "push a" > a.dat
407 git add .gitattributes a.dat
408 git commit -m "add a.dat"
410 git lfs push --object-id origin \
411 4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 \
413 grep "Uploading LFS objects: 100% (1/1), 7 B" push.log
415 echo "push b" > b.dat
417 git commit -m "add b.dat"
419 git lfs push --object-id origin \
420 4c48d2a6991c9895bcddcf027e1e4907280bcf21975492b1afbade396d6a3340 \
421 82be50ad35070a4ef3467a0a650c52d5b637035e7ad02c36652e59d01ba282b7 \
423 grep "Uploading LFS objects: 100% (2/2), 14 B" push.log
427 begin_test "push modified files"
431 reponame="$(basename "$0" ".sh")-modified"
432 setup_remote_repo "$reponame"
433 clone_repo "$reponame" "$reponame"
435 git lfs track "*.dat"
436 # generate content we'll use
437 content1="filecontent1"
438 content2="filecontent2"
439 content3="filecontent3"
440 content4="filecontent4"
441 content5="filecontent5"
442 oid1=$(calc_oid "$content1")
443 oid2=$(calc_oid "$content2")
444 oid3=$(calc_oid "$content3")
445 oid4=$(calc_oid "$content4")
446 oid5=$(calc_oid "$content5")
450 \"CommitDate\":\"$(get_date -6m)\",
452 {\"Filename\":\"file1.dat\",\"Size\":${#content1}, \"Data\":\"$content1\"}]
455 \"CommitDate\":\"$(get_date -3m)\",
457 {\"Filename\":\"file1.dat\",\"Size\":${#content2}, \"Data\":\"$content2\"}]
460 \"CommitDate\":\"$(get_date -1m)\",
461 \"NewBranch\":\"other_branch\",
463 {\"Filename\":\"file1.dat\",\"Size\":${#content5}, \"Data\":\"$content5\"}]
466 \"CommitDate\":\"$(get_date -1m)\",
467 \"ParentBranches\":[\"master\"],
469 {\"Filename\":\"file1.dat\",\"Size\":${#content3}, \"Data\":\"$content3\"},
470 {\"Filename\":\"file2.dat\",\"Size\":${#content4}, \"Data\":\"$content4\"}]
472 ]" | lfstest-testutils addcommits
474 git lfs push origin master
475 git lfs push origin other_branch
476 assert_server_object "$reponame" "$oid1"
477 assert_server_object "$reponame" "$oid2"
478 assert_server_object "$reponame" "$oid3"
479 assert_server_object "$reponame" "$oid4"
480 assert_server_object "$reponame" "$oid5"
484 begin_test "push with invalid remote"
488 git lfs push not-a-remote 2>&1 | tee push.log
489 grep "Invalid remote name" push.log
493 begin_test "push ambiguous branch name"
497 reponame="$(basename "$0" ".sh")-ambiguous-branch"
498 setup_remote_repo "$reponame"
499 clone_repo "$reponame" "$reponame"
502 git lfs track "*.dat" 2>&1 | tee track.log
503 grep "Tracking \"\*.dat\"" track.log
506 # generate content we'll use
507 for ((a=0; a < NUMFILES ; a++))
509 content[$a]="filecontent$a"
510 oid[$a]=$(calc_oid "${content[$a]}")
515 \"CommitDate\":\"$(get_date -10d)\",
517 {\"Filename\":\"file1.dat\",\"Size\":${#content[0]}, \"Data\":\"${content[0]}\"},
518 {\"Filename\":\"file2.dat\",\"Size\":${#content[1]}, \"Data\":\"${content[1]}\"}]
521 \"NewBranch\":\"ambiguous\",
522 \"CommitDate\":\"$(get_date -5d)\",
524 {\"Filename\":\"file3.dat\",\"Size\":${#content[2]}, \"Data\":\"${content[2]}\"}]
527 \"CommitDate\":\"$(get_date -2d)\",
529 {\"Filename\":\"file4.dat\",\"Size\":${#content[3]}, \"Data\":\"${content[3]}\"}]
532 \"ParentBranches\":[\"master\"],
533 \"CommitDate\":\"$(get_date -1d)\",
535 {\"Filename\":\"file1.dat\",\"Size\":${#content[4]}, \"Data\":\"${content[4]}\"}]
537 ]" | lfstest-testutils addcommits
539 # create tag with same name as branch
542 # lfs push master, should work
543 git lfs push origin master
545 # push ambiguous, does not fail since lfs scans git with sha, not ref name
546 git lfs push origin ambiguous
550 begin_test "push (retry with expired actions)"
554 reponame="push_retry_expired_action"
555 setup_remote_repo "$reponame"
556 clone_repo "$reponame" "$reponame"
558 git lfs track "*.dat"
559 contents="return-expired-action"
560 contents_oid="$(calc_oid "$contents")"
561 contents_size="$(printf "$contents" | wc -c | awk '{ print $1 }')"
562 printf "$contents" > a.dat
563 git add .gitattributes a.dat
565 git commit -m "add a.dat, .gitattributes" 2>&1 | tee commit.log
566 grep "master (root-commit)" commit.log
567 grep "2 files changed" commit.log
568 grep "create mode 100644 a.dat" commit.log
569 grep "create mode 100644 .gitattributes" commit.log
571 GIT_TRACE=1 git push origin master 2>&1 | tee push.log
573 expected="enqueue retry #1 for \"$contents_oid\" (size: $contents_size): LFS: tq: action \"upload\" expires at"
575 grep "$expected" push.log
576 grep "Uploading LFS objects: 100% (1/1), 21 B" push.log
580 begin_test "push to raw remote url"
584 setup_remote_repo "push-raw"
589 git lfs track "*.dat"
592 contents_oid=$(calc_oid "$contents")
594 printf "$contents" > raw.dat
595 git add raw.dat .gitattributes
596 git commit -m "add" 2>&1 | tee commit.log
597 grep "master (root-commit)" commit.log
598 grep "2 files changed" commit.log
599 grep "create mode 100644 raw.dat" commit.log
600 grep "create mode 100644 .gitattributes" commit.log
602 refute_server_object push-raw "$contents_oid"
604 git lfs push $GITSERVER/push-raw master
606 assert_server_object push-raw "$contents_oid"
610 begin_test "push (with invalid object size)"
614 reponame="push-invalid-object-size"
615 setup_remote_repo "$reponame"
616 clone_repo "$reponame" "$reponame"
618 git lfs track "*.dat"
619 contents="return-invalid-size"
620 printf "$contents" > a.dat
622 git add a.dat .gitattributes
623 git commit -m "add a.dat, .gitattributes" 2>&1 | tee commit.log
624 grep "master (root-commit)" commit.log
625 grep "2 files changed" commit.log
626 grep "create mode 100644 a.dat" commit.log
627 grep "create mode 100644 .gitattributes" commit.log
630 git push origin master 2>&1 2> push.log
634 grep "invalid size (got: -1)" push.log
635 [ "0" -eq "$(grep -c "panic" push.log)" ]
638 refute_server_object "$reponame" "$(calc_oid "$contents")"
642 begin_test "push with deprecated _links"
646 reponame="$(basename "$0" ".sh")-deprecated"
647 setup_remote_repo "$reponame"
648 clone_repo "$reponame" "$reponame"
650 git lfs track "*.dat"
651 git add .gitattributes
652 git commit -m "initial commit"
654 contents="send-deprecated-links"
655 contents_oid="$(calc_oid "$contents")"
656 printf "$contents" > a.dat
658 git commit -m "add a.dat"
660 git push origin master
662 assert_server_object "$reponame" "$contents_oid"
665 begin_test "push with missing objects (lfs.allowincompletepush=t)"
669 reponame="push-with-missing-objects"
670 setup_remote_repo "$reponame"
671 clone_repo "$reponame" "$reponame"
673 git lfs track "*.dat"
674 git add .gitattributes
675 git commit -m "initial commit"
678 present_oid="$(calc_oid "$present")"
679 printf "$present" > present.dat
682 missing_oid="$(calc_oid "$missing")"
683 printf "$missing" > missing.dat
685 git add missing.dat present.dat
686 git commit -m "add objects"
689 git commit -m "remove missing"
691 # :fire: the "missing" object
692 missing_oid_part_1="$(echo "$missing_oid" | cut -b 1-2)"
693 missing_oid_part_2="$(echo "$missing_oid" | cut -b 3-4)"
694 missing_oid_path=".git/lfs/objects/$missing_oid_part_1/$missing_oid_part_2/$missing_oid"
695 rm "$missing_oid_path"
697 git push origin master 2>&1 | tee push.log
698 if [ "0" -ne "${PIPESTATUS[0]}" ]; then
699 echo >&2 "fatal: expected \`git push origin master\` to succeed ..."
703 grep "LFS upload missing objects" push.log
704 grep " (missing) missing.dat ($missing_oid)" push.log
706 assert_server_object "$reponame" "$present_oid"
707 refute_server_object "$reponame" "$missing_oid"
711 begin_test "push reject missing objects (lfs.allowincompletepush=f)"
715 reponame="push-reject-missing-objects"
716 setup_remote_repo "$reponame"
717 clone_repo "$reponame" "$reponame"
719 git lfs track "*.dat"
720 git add .gitattributes
721 git commit -m "initial commit"
724 present_oid="$(calc_oid "$present")"
725 printf "$present" > present.dat
728 missing_oid="$(calc_oid "$missing")"
729 printf "$missing" > missing.dat
731 git add missing.dat present.dat
732 git commit -m "add objects"
735 git commit -m "remove missing"
737 # :fire: the "missing" object
738 missing_oid_part_1="$(echo "$missing_oid" | cut -b 1-2)"
739 missing_oid_part_2="$(echo "$missing_oid" | cut -b 3-4)"
740 missing_oid_path=".git/lfs/objects/$missing_oid_part_1/$missing_oid_part_2/$missing_oid"
741 rm "$missing_oid_path"
743 git config "lfs.allowincompletepush" "false"
745 git push origin master 2>&1 | tee push.log
746 if [ "1" -ne "${PIPESTATUS[0]}" ]; then
747 echo >&2 "fatal: expected \`git push origin master\` to succeed ..."
751 grep "no such file or directory" push.log || # unix
752 grep "cannot find the file" push.log # windows
753 grep "failed to push some refs" push.log
755 refute_server_object "$reponame" "$present_oid"
756 refute_server_object "$reponame" "$missing_oid"