|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +. "test/testlib.sh" |
| 4 | + |
| 5 | +begin_test "pull" |
| 6 | +( |
| 7 | + set -e |
| 8 | + |
| 9 | + reponame="$(basename "$0" ".sh")" |
| 10 | + setup_remote_repo "$reponame" |
| 11 | + |
| 12 | + clone_repo "$reponame" clone |
| 13 | + |
| 14 | + clone_repo "$reponame" repo |
| 15 | + |
| 16 | + git lfs track "*.dat" 2>&1 | tee track.log |
| 17 | + grep "Tracking \*.dat" track.log |
| 18 | + |
| 19 | + contents="a" |
| 20 | + contents_oid=$(printf "$contents" | shasum -a 256 | cut -f 1 -d " ") |
| 21 | + |
| 22 | + printf "$contents" > a.dat |
| 23 | + git add a.dat |
| 24 | + git add .gitattributes |
| 25 | + git commit -m "add a.dat" 2>&1 | tee commit.log |
| 26 | + grep "master (root-commit)" commit.log |
| 27 | + grep "2 files changed" commit.log |
| 28 | + grep "create mode 100644 a.dat" commit.log |
| 29 | + grep "create mode 100644 .gitattributes" commit.log |
| 30 | + |
| 31 | + [ "a" = "$(cat a.dat)" ] |
| 32 | + |
| 33 | + assert_pointer "master" "a.dat" "$contents_oid" 1 |
| 34 | + |
| 35 | + refute_server_object "$reponame" "$contents_oid" |
| 36 | + |
| 37 | + git push origin master 2>&1 | tee push.log |
| 38 | + grep "(1 of 1 files)" push.log |
| 39 | + grep "master -> master" push.log |
| 40 | + |
| 41 | + assert_server_object "$reponame" "$contents_oid" |
| 42 | + |
| 43 | + # Add a file in a different branch |
| 44 | + git checkout -b newbranch |
| 45 | + b="b" |
| 46 | + b_oid=$(printf "$b" | shasum -a 256 | cut -f 1 -d " ") |
| 47 | + printf "$b" > b.dat |
| 48 | + git add b.dat |
| 49 | + git commit -m "add b.dat" |
| 50 | + assert_pointer "newbranch" "b.dat" "$b_oid" 1 |
| 51 | + |
| 52 | + git push origin newbranch |
| 53 | + assert_server_object "$reponame" "$b_oid" |
| 54 | + |
| 55 | + # change to the clone's working directory |
| 56 | + cd ../clone |
| 57 | + |
| 58 | + git pull 2>&1 | grep "Downloading a.dat (1 B)" |
| 59 | + |
| 60 | + [ "a" = "$(cat a.dat)" ] |
| 61 | + |
| 62 | + assert_pointer "master" "a.dat" "$contents_oid" 1 |
| 63 | + |
| 64 | + |
| 65 | + # Remove the working directory and lfs files |
| 66 | + rm a.dat |
| 67 | + rm -rf .git/lfs/objects |
| 68 | + |
| 69 | + git lfs pull 2>&1 | grep "(1 of 1 files)" |
| 70 | + |
| 71 | + [ "a" = "$(cat a.dat)" ] |
| 72 | + |
| 73 | + git checkout newbranch |
| 74 | + git checkout master |
| 75 | + rm -rf .git/lfs/objects |
| 76 | + |
| 77 | + git lfs pull newbranch 2>&1 | grep "(2 of 2 files)" |
| 78 | +) |
| 79 | +end_test |
0 commit comments