2 # This is a sample Git LFS test. See test/README.md and testhelpers.sh for
7 begin_test "batch transfer"
11 # This initializes a new bare git repository in test/remote.
12 # These remote repositories are global to every test, so keep the names
14 reponame1="$(basename "$0" ".sh")"
15 reponame2="CAPITALLETTERS"
16 reponame=$reponame1$reponame2
17 setup_remote_repo "$reponame"
19 # Clone the repository from the test Git server. This is empty, and will be
20 # used to test a "git pull" below. The repo is cloned to $TRASHDIR/clone
21 clone_repo "$reponame" clone
23 # Clone the repository again to $TRASHDIR/repo. This will be used to commit
25 clone_repo "$reponame" repo
27 # This executes Git LFS from the local repo that was just cloned.
28 git lfs track "*.dat" 2>&1 | tee track.log
29 grep "Tracking \"\*.dat\"" track.log
32 contents_oid=$(calc_oid "$contents")
34 printf "$contents" > a.dat
36 git add .gitattributes
37 git commit -m "add a.dat" 2>&1 | tee commit.log
38 grep "master (root-commit)" commit.log
39 grep "2 files changed" commit.log
40 grep "create mode 100644 a.dat" commit.log
41 grep "create mode 100644 .gitattributes" commit.log
43 [ "a" = "$(cat a.dat)" ]
45 # This is a small shell function that runs several git commands together.
46 assert_pointer "master" "a.dat" "$contents_oid" 1
48 refute_server_object "$reponame" "$contents_oid"
50 # This pushes to the remote repository set up at the top of the test.
51 git push origin master 2>&1 | tee push.log
52 grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
53 grep "master -> master" push.log
55 assert_server_object "$reponame" "$contents_oid"
57 # change to the clone's working directory
62 [ "a" = "$(cat a.dat)" ]
64 assert_pointer "master" "a.dat" "$contents_oid" 1
68 begin_test "batch transfers occur in reverse order by size"
72 reponame="batch-order-test"
73 setup_remote_repo "$reponame"
74 clone_repo "$reponame" "$reponame"
77 git add .gitattributes
78 git commit -m "initial commit"
80 small_contents="small"
81 small_oid="$(calc_oid "$small_contents")"
82 printf "$small_contents" > small.dat
84 bigger_contents="bigger"
85 bigger_oid="$(calc_oid "$bigger_contents")"
86 printf "$bigger_contents" > bigger.dat
89 git commit -m "add small and large objects"
91 GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log
93 batch="$(grep "{\"operation\":\"upload\"" push.log | head -1)"
95 pos_small="$(substring_position "$batch" "$small_oid")"
96 pos_large="$(substring_position "$batch" "$bigger_oid")"
98 # Assert that the the larger object shows up earlier in the batch than the
100 [ "$pos_large" -lt "$pos_small" ]
104 begin_test "batch transfers with ssh endpoint"
109 setup_remote_repo "$reponame"
110 clone_repo "$reponame" "$reponame"
112 sshurl="${GITSERVER/http:\/\//ssh://git@}/$reponame"
113 git config lfs.url "$sshurl"
117 oid="$(calc_oid "$contents")"
118 git lfs track "*.dat"
119 printf "$contents" > test.dat
120 git add .gitattributes test.dat
121 git commit -m "initial commit"
123 git push origin master 2>&1
127 begin_test "batch transfers with ntlm server"
132 setup_remote_repo "$reponame"
134 printf "ntlmdomain\\\ntlmuser:ntlmpass" > "$CREDSDIR/127.0.0.1--$reponame"
136 clone_repo "$reponame" "$reponame"
139 oid="$(calc_oid "$contents")"
140 git lfs track "*.dat"
141 printf "$contents" > test.dat
142 git add .gitattributes test.dat
143 git commit -m "initial commit"
145 GIT_CURL_VERBOSE=1 git push origin master 2>&1