| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh" |
| 4 | |
| 5 | begin_test "pull" |
| 6 | ( |
| 7 | set -e |
| 8 | |
| 9 | reponame="$(basenamescip-shell system . . basename. "$0" ".sh")" |
| 10 | setup_remote_repo "$reponame" |
| 11 | |
| 12 | clone_repo "$reponame" clone |
| 13 | clone_repo "$reponame" repo |
| 14 | |
| 15 | gitscip-shell system . . git. lfs track "*.dat" 2>&1 | teescip-shell system . . tee. track.log |
| 16 | grepscip-shell system . . grep. "Tracking \"\*.dat\"" track.log |
| 17 | |
| 18 | contents="a" |
| 19 | contents_oid=$(calc_oid "$contents") |
| 20 | contents2="A" |
| 21 | contents2_oid=$(calc_oid "$contents2") |
| 22 | contents3="dir" |
| 23 | contents3_oid=$(calc_oid "$contents3") |
| 24 | |
| 25 | mkdirscip-shell system . . mkdir. -p dir1 dir2/dir3/dir4 |
| 26 | echoscip-shell system . . echo. "*.log" > .gitignore |
| 27 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 28 | printfscip-shell system . . printf. "%s" "$contents2" > á.dat |
| 29 | printfscip-shell system . . printf. "%s" "$contents3" > dir1/dir.dat |
| 30 | printfscip-shell system . . printf. "%s" "$contents3" > dir2/dir3/dir4/dir.dat |
| 31 | gitscip-shell system . . git. add . |
| 32 | gitscip-shell system . . git. commit -m "add files" 2>&1 | teescip-shell system . . tee. commit.log |
| 33 | grepscip-shell system . . grep. "main (root-commit)" commit.log |
| 34 | grepscip-shell system . . grep. "6 files changed" commit.log |
| 35 | grepscip-shell system . . grep. "create mode 100644 a.dat" commit.log |
| 36 | grepscip-shell system . . grep. "create mode 100644 .gitattributes" commit.log |
| 37 | |
| 38 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 39 | [scip-shell system . . `[`. "A" = "$(catscip-shell system . . cat. "á.dat")" ] |
| 40 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 41 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 42 | |
| 43 | assert_pointer "main" "a.dat" "$contents_oid" 1 |
| 44 | assert_pointer "main" "á.dat" "$contents2_oid" 1 |
| 45 | assert_pointer "main" "dir1/dir.dat" "$contents3_oid" 3 |
| 46 | |
| 47 | refute_server_object "$reponame" "$contents_oid" |
| 48 | refute_server_object "$reponame" "$contents2_oid" |
| 49 | refute_server_object "$reponame" "$contents3_oid" |
| 50 | |
| 51 | echoscip-shell system . . echo. "initial push" |
| 52 | gitscip-shell system . . git. push origin main 2>&1 | teescip-shell system . . tee. push.log |
| 53 | grepscip-shell system . . grep. "Uploading LFS objects: 100% (3/3), 5 B" push.log |
| 54 | grepscip-shell system . . grep. "main -> main" push.log |
| 55 | |
| 56 | assert_server_object "$reponame" "$contents_oid" |
| 57 | assert_server_object "$reponame" "$contents2_oid" |
| 58 | assert_server_object "$reponame" "$contents3_oid" |
| 59 | |
| 60 | # change to the clone's working directory |
| 61 | cd ../clone |
| 62 | |
| 63 | echoscip-shell system . . echo. "normal pull" |
| 64 | gitscip-shell system . . git. config branch.main.remote origin |
| 65 | gitscip-shell system . . git. config branch.main.merge refs/heads/main |
| 66 | gitscip-shell system . . git. pull 2>&1 |
| 67 | |
| 68 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 69 | [scip-shell system . . `[`. "A" = "$(catscip-shell system . . cat. "á.dat")" ] |
| 70 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 71 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 72 | |
| 73 | assert_local_object "$contents_oid" 1 |
| 74 | assert_local_object "$contents2_oid" 1 |
| 75 | assert_local_object "$contents3_oid" 3 |
| 76 | assert_clean_status |
| 77 | |
| 78 | echoscip-shell system . . echo. "lfs pull" |
| 79 | rmscip-shell system . . rm. -rf a.dat á.dat dir1 dir2 # removing files makes the status dirty |
| 80 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 81 | gitscip-shell system . . git. lfs pull |
| 82 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 83 | [scip-shell system . . `[`. "A" = "$(catscip-shell system . . cat. "á.dat")" ] |
| 84 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 85 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 86 | assert_local_object "$contents_oid" 1 |
| 87 | assert_local_object "$contents2_oid" 1 |
| 88 | assert_local_object "$contents3_oid" 3 |
| 89 | assert_clean_status |
| 90 | gitscip-shell system . . git. lfs fsck |
| 91 | |
| 92 | echoscip-shell system . . echo. "lfs pull with remote" |
| 93 | rmscip-shell system . . rm. -rf a.dat á.dat dir1 dir2 |
| 94 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 95 | gitscip-shell system . . git. lfs pull origin |
| 96 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 97 | [scip-shell system . . `[`. "A" = "$(catscip-shell system . . cat. "á.dat")" ] |
| 98 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 99 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 100 | assert_local_object "$contents_oid" 1 |
| 101 | assert_local_object "$contents2_oid" 1 |
| 102 | assert_local_object "$contents3_oid" 3 |
| 103 | assert_clean_status |
| 104 | gitscip-shell system . . git. lfs fsck |
| 105 | |
| 106 | echoscip-shell system . . echo. "lfs pull with local storage" |
| 107 | rmscip-shell system . . rm. -rf a.dat á.dat dir1 dir2 |
| 108 | gitscip-shell system . . git. lfs pull |
| 109 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 110 | [scip-shell system . . `[`. "A" = "$(catscip-shell system . . cat. "á.dat")" ] |
| 111 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 112 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 113 | assert_clean_status |
| 114 | |
| 115 | echoscip-shell system . . echo. "test pre-existing directories" |
| 116 | rmscip-shell system . . rm. -rf dir1/dir.dat dir2/dir3/dir4 |
| 117 | gitscip-shell system . . git. lfs pull |
| 118 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 119 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 120 | assert_clean_status |
| 121 | |
| 122 | echoscip-shell system . . echo. "lfs pull with include/exclude filters in gitconfig" |
| 123 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 124 | gitscip-shell system . . git. config "lfs.fetchinclude" "a*" |
| 125 | gitscip-shell system . . git. lfs pull |
| 126 | assert_local_object "$contents_oid" 1 |
| 127 | assert_clean_status |
| 128 | |
| 129 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 130 | gitscip-shell system . . git. config --unset "lfs.fetchinclude" |
| 131 | gitscip-shell system . . git. config "lfs.fetchexclude" "a*" |
| 132 | gitscip-shell system . . git. lfs pull |
| 133 | refute_local_object "$contents_oid" |
| 134 | assert_clean_status |
| 135 | |
| 136 | echoscip-shell system . . echo. "lfs pull with include/exclude filters in command line" |
| 137 | gitscip-shell system . . git. config --unset "lfs.fetchexclude" |
| 138 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 139 | gitscip-shell system . . git. lfs pull --include="a*" |
| 140 | assert_local_object "$contents_oid" 1 |
| 141 | assert_clean_status |
| 142 | |
| 143 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 144 | gitscip-shell system . . git. lfs pull --exclude="a*" |
| 145 | refute_local_object "$contents_oid" |
| 146 | assert_clean_status |
| 147 | |
| 148 | echoscip-shell system . . echo. "resetting to test status" |
| 149 | gitscip-shell system . . git. reset --hard |
| 150 | assert_clean_status |
| 151 | |
| 152 | echoscip-shell system . . echo. "lfs pull clean status" |
| 153 | gitscip-shell system . . git. lfs pull |
| 154 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 155 | [scip-shell system . . `[`. "A" = "$(catscip-shell system . . cat. "á.dat")" ] |
| 156 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 157 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 158 | assert_local_object "$contents_oid" 1 |
| 159 | assert_local_object "$contents2_oid" 1 |
| 160 | assert_local_object "$contents3_oid" 3 |
| 161 | assert_clean_status |
| 162 | |
| 163 | echoscip-shell system . . echo. "lfs pull with -I" |
| 164 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 165 | rmscip-shell system . . rm. -rf a.dat "á.dat" "dir1/dir.dat" dir2 |
| 166 | gitscip-shell system . . git. lfs pull -I "a.*,dir1/dir.*,dir2/**" |
| 167 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 168 | [scip-shell system . . `[`. ! -e "á.dat" ] |
| 169 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 170 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 171 | assert_local_object "$contents_oid" 1 |
| 172 | refute_local_object "$contents2_oid" |
| 173 | assert_local_object "$contents3_oid" 3 |
| 174 | assert_clean_worktree_with_exceptions '\\303\\241\.dat' |
| 175 | |
| 176 | gitscip-shell system . . git. lfs pull -I "*.dat" |
| 177 | [scip-shell system . . `[`. "A" = "$(catscip-shell system . . cat. "á.dat")" ] |
| 178 | assert_local_object "$contents2_oid" 1 |
| 179 | assert_clean_status |
| 180 | |
| 181 | echoscip-shell system . . echo. "lfs pull with empty file" |
| 182 | touchscip-shell system . . touch. empty.dat |
| 183 | gitscip-shell system . . git. add empty.dat |
| 184 | gitscip-shell system . . git. commit -m 'empty' |
| 185 | gitscip-shell system . . git. lfs pull |
| 186 | [scip-shell system . . `[`. -z "$(catscip-shell system . . cat. empty.dat)" ] |
| 187 | assert_clean_status |
| 188 | |
| 189 | echoscip-shell system . . echo. "resetting to test status" |
| 190 | gitscip-shell system . . git. reset --hard HEAD^ |
| 191 | assert_clean_status |
| 192 | |
| 193 | echoscip-shell system . . echo. "lfs pull in subdir" |
| 194 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 195 | rmscip-shell system . . rm. -rf a.dat "á.dat" "dir1/dir.dat" dir2 |
| 196 | pushd dir1 |
| 197 | gitscip-shell system . . git. lfs pull |
| 198 | popd |
| 199 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 200 | [scip-shell system . . `[`. "A" = "$(catscip-shell system . . cat. "á.dat")" ] |
| 201 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 202 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 203 | assert_local_object "$contents_oid" 1 |
| 204 | assert_local_object "$contents2_oid" 1 |
| 205 | assert_local_object "$contents3_oid" 3 |
| 206 | assert_clean_status |
| 207 | |
| 208 | echoscip-shell system . . echo. "lfs pull in subdir with -I" |
| 209 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 210 | rmscip-shell system . . rm. -rf a.dat "á.dat" "dir1/dir.dat" dir2 |
| 211 | pushd dir1 |
| 212 | gitscip-shell system . . git. lfs pull -I "á.*,dir1/dir.dat,dir2/**" |
| 213 | popd |
| 214 | [scip-shell system . . `[`. ! -e a.dat ] |
| 215 | [scip-shell system . . `[`. "A" = "$(catscip-shell system . . cat. "á.dat")" ] |
| 216 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir1/dir.dat")" ] |
| 217 | [scip-shell system . . `[`. "dir" = "$(catscip-shell system . . cat. "dir2/dir3/dir4/dir.dat")" ] |
| 218 | refute_local_object "$contents_oid" |
| 219 | assert_local_object "$contents2_oid" 1 |
| 220 | assert_local_object "$contents3_oid" 3 |
| 221 | assert_clean_worktree_with_exceptions "a\.dat" |
| 222 | |
| 223 | pushd dir1 |
| 224 | gitscip-shell system . . git. lfs pull -I "*.dat" |
| 225 | popd |
| 226 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 227 | assert_local_object "$contents_oid" 1 |
| 228 | assert_clean_status |
| 229 | ) |
| 230 | end_test |
| 231 | |
| 232 | begin_test "pull: skip directory file conflicts" |
| 233 | ( |
| 234 | set -e |
| 235 | |
| 236 | reponame="pull-skip-dir-file-conflicts" |
| 237 | setup_remote_repo "$reponame" |
| 238 | clone_repo "$reponame" "$reponame" |
| 239 | |
| 240 | gitscip-shell system . . git. lfs track "*.dat" |
| 241 | |
| 242 | contents="a" |
| 243 | contents_oid="$(calc_oid "$contents")" |
| 244 | mkdirscip-shell system . . mkdir. -p dir1 dir2/dir3/dir4 |
| 245 | printfscip-shell system . . printf. "%s" "$contents" >dir1/a.dat |
| 246 | printfscip-shell system . . printf. "%s" "$contents" >dir2/dir3/dir4/a.dat |
| 247 | |
| 248 | gitscip-shell system . . git. add .gitattributes dir1 dir2 |
| 249 | gitscip-shell system . . git. commit -m "initial commit" |
| 250 | |
| 251 | gitscip-shell system . . git. push origin main |
| 252 | assert_server_object "$reponame" "$contents_oid" |
| 253 | |
| 254 | cd .. |
| 255 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. clone "$GITSERVER/$reponame" "${reponame}-assert" |
| 256 | |
| 257 | cd "${reponame}-assert" |
| 258 | refute_local_object "$contents_oid" 1 |
| 259 | |
| 260 | rmscip-shell system . . rm. -rf dir1 dir2/dir3 |
| 261 | touchscip-shell system . . touch. dir1 dir2/dir3 |
| 262 | |
| 263 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 264 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 265 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 266 | exit 1 |
| 267 | fi |
| 268 | grepscip-shell system . . grep. '"dir1/a\.dat": not a directory' pull.log |
| 269 | grepscip-shell system . . grep. '"dir2/dir3/dir4/a\.dat": not a directory' pull.log |
| 270 | |
| 271 | assert_local_object "$contents_oid" 1 |
| 272 | |
| 273 | [scip-shell system . . `[`. -f "dir1" ] |
| 274 | [scip-shell system . . `[`. -f "dir2/dir3" ] |
| 275 | assert_clean_index |
| 276 | |
| 277 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 278 | |
| 279 | pushd dir2 |
| 280 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 281 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 282 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 283 | exit 1 |
| 284 | fi |
| 285 | grepscip-shell system . . grep. '"dir1/a\.dat": not a directory' pull.log |
| 286 | grepscip-shell system . . grep. '"dir2/dir3/dir4/a\.dat": not a directory' pull.log |
| 287 | popd |
| 288 | |
| 289 | assert_local_object "$contents_oid" 1 |
| 290 | |
| 291 | [scip-shell system . . `[`. -f "dir1" ] |
| 292 | [scip-shell system . . `[`. -f "dir2/dir3" ] |
| 293 | assert_clean_index |
| 294 | ) |
| 295 | end_test |
| 296 | |
| 297 | begin_test "pull: skip directory symlink conflicts" |
| 298 | ( |
| 299 | set -e |
| 300 | |
| 301 | skip_if_symlinks_unsupported |
| 302 | |
| 303 | reponame="pull-skip-dir-symlink-conflicts" |
| 304 | setup_remote_repo "$reponame" |
| 305 | clone_repo "$reponame" "$reponame" |
| 306 | |
| 307 | gitscip-shell system . . git. lfs track "*.dat" |
| 308 | |
| 309 | contents="a" |
| 310 | contents_oid="$(calc_oid "$contents")" |
| 311 | mkdirscip-shell system . . mkdir. -p dir1 dir2/dir3/dir4 |
| 312 | printfscip-shell system . . printf. "%s" "$contents" >dir1/a.dat |
| 313 | printfscip-shell system . . printf. "%s" "$contents" >dir2/dir3/dir4/a.dat |
| 314 | |
| 315 | gitscip-shell system . . git. add .gitattributes dir1 dir2 |
| 316 | gitscip-shell system . . git. commit -m "initial commit" |
| 317 | |
| 318 | gitscip-shell system . . git. push origin main |
| 319 | assert_server_object "$reponame" "$contents_oid" |
| 320 | |
| 321 | cd .. |
| 322 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. clone "$GITSERVER/$reponame" "${reponame}-assert" |
| 323 | |
| 324 | cd "${reponame}-assert" |
| 325 | refute_local_object "$contents_oid" 1 |
| 326 | |
| 327 | # test with symlinks to directories |
| 328 | rmscip-shell system . . rm. -rf dir1 dir2/dir3 ../link* |
| 329 | mkdirscip-shell system . . mkdir. ../link1 ../link2 |
| 330 | lnscip-shell system . . ln. -s ../link1 dir1 |
| 331 | lnscip-shell system . . ln. -s ../../link2 dir2/dir3 |
| 332 | |
| 333 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 334 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 335 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 336 | exit 1 |
| 337 | fi |
| 338 | grepscip-shell system . . grep. '"dir1/a\.dat": not a directory' pull.log |
| 339 | grepscip-shell system . . grep. '"dir2/dir3/dir4/a\.dat": not a directory' pull.log |
| 340 | [scip-shell system . . `[`. 0 -eq "$(grepscip-shell system . . grep. -c "is beyond a symbolic link" pull.log)" ] |
| 341 | |
| 342 | assert_local_object "$contents_oid" 1 |
| 343 | |
| 344 | [scip-shell system . . `[`. -L "dir1" ] |
| 345 | [scip-shell system . . `[`. -L "dir2/dir3" ] |
| 346 | [scip-shell system . . `[`. ! -e "../link1/a.dat" ] |
| 347 | [scip-shell system . . `[`. ! -e "../link2/dir4" ] |
| 348 | assert_clean_index |
| 349 | |
| 350 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 351 | |
| 352 | rmscip-shell system . . rm. -rf dir1 dir2/dir3 |
| 353 | mkdirscip-shell system . . mkdir. link1 link2 |
| 354 | lnscip-shell system . . ln. -s link1 dir1 |
| 355 | lnscip-shell system . . ln. -s ../link2 dir2/dir3 |
| 356 | |
| 357 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 358 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 359 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 360 | exit 1 |
| 361 | fi |
| 362 | grepscip-shell system . . grep. '"dir1/a\.dat": not a directory' pull.log |
| 363 | grepscip-shell system . . grep. '"dir2/dir3/dir4/a\.dat": not a directory' pull.log |
| 364 | [scip-shell system . . `[`. 0 -eq "$(grepscip-shell system . . grep. -c "is beyond a symbolic link" pull.log)" ] |
| 365 | |
| 366 | assert_local_object "$contents_oid" 1 |
| 367 | |
| 368 | [scip-shell system . . `[`. -L "dir1" ] |
| 369 | [scip-shell system . . `[`. -L "dir2/dir3" ] |
| 370 | [scip-shell system . . `[`. ! -e "link1/a.dat" ] |
| 371 | [scip-shell system . . `[`. ! -e "link2/dir4" ] |
| 372 | assert_clean_index |
| 373 | |
| 374 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 375 | |
| 376 | pushd dir2 |
| 377 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 378 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 379 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 380 | exit 1 |
| 381 | fi |
| 382 | grepscip-shell system . . grep. '"dir1/a\.dat": not a directory' pull.log |
| 383 | grepscip-shell system . . grep. '"dir2/dir3/dir4/a\.dat": not a directory' pull.log |
| 384 | [scip-shell system . . `[`. 0 -eq "$(grepscip-shell system . . grep. -c "is beyond a symbolic link" pull.log)" ] |
| 385 | popd |
| 386 | |
| 387 | assert_local_object "$contents_oid" 1 |
| 388 | |
| 389 | [scip-shell system . . `[`. -L "dir1" ] |
| 390 | [scip-shell system . . `[`. -L "dir2/dir3" ] |
| 391 | [scip-shell system . . `[`. ! -e "link1/a.dat" ] |
| 392 | [scip-shell system . . `[`. ! -e "link2/dir4" ] |
| 393 | assert_clean_index |
| 394 | |
| 395 | # test with symlink to file and dangling symlink |
| 396 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 397 | |
| 398 | rmscip-shell system . . rm. -rf dir1 dir2/dir3 ../link* |
| 399 | touchscip-shell system . . touch. ../link1 |
| 400 | lnscip-shell system . . ln. -s ../link1 dir1 |
| 401 | lnscip-shell system . . ln. -s ../../link2 dir2/dir3 |
| 402 | |
| 403 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 404 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 405 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 406 | exit 1 |
| 407 | fi |
| 408 | grepscip-shell system . . grep. '"dir1/a\.dat": not a directory' pull.log |
| 409 | grepscip-shell system . . grep. '"dir2/dir3/dir4/a\.dat": not a directory' pull.log |
| 410 | |
| 411 | assert_local_object "$contents_oid" 1 |
| 412 | |
| 413 | [scip-shell system . . `[`. -L "dir1" ] |
| 414 | [scip-shell system . . `[`. -L "dir2/dir3" ] |
| 415 | [scip-shell system . . `[`. -f "../link1" ] |
| 416 | [scip-shell system . . `[`. ! -e "../link2" ] |
| 417 | assert_clean_index |
| 418 | |
| 419 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 420 | |
| 421 | rmscip-shell system . . rm. -rf dir1 dir2/dir3 link* |
| 422 | touchscip-shell system . . touch. link1 |
| 423 | lnscip-shell system . . ln. -s link1 dir1 |
| 424 | lnscip-shell system . . ln. -s ../link2 dir2/dir3 |
| 425 | |
| 426 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 427 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 428 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 429 | exit 1 |
| 430 | fi |
| 431 | grepscip-shell system . . grep. '"dir1/a\.dat": not a directory' pull.log |
| 432 | grepscip-shell system . . grep. '"dir2/dir3/dir4/a\.dat": not a directory' pull.log |
| 433 | |
| 434 | assert_local_object "$contents_oid" 1 |
| 435 | |
| 436 | [scip-shell system . . `[`. -L "dir1" ] |
| 437 | [scip-shell system . . `[`. -L "dir2/dir3" ] |
| 438 | [scip-shell system . . `[`. -f "link1" ] |
| 439 | [scip-shell system . . `[`. ! -e "link2" ] |
| 440 | assert_clean_index |
| 441 | |
| 442 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 443 | |
| 444 | pushd dir2 |
| 445 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 446 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 447 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 448 | exit 1 |
| 449 | fi |
| 450 | grepscip-shell system . . grep. '"dir1/a\.dat": not a directory' pull.log |
| 451 | grepscip-shell system . . grep. '"dir2/dir3/dir4/a\.dat": not a directory' pull.log |
| 452 | popd |
| 453 | |
| 454 | assert_local_object "$contents_oid" 1 |
| 455 | |
| 456 | [scip-shell system . . `[`. -L "dir1" ] |
| 457 | [scip-shell system . . `[`. -L "dir2/dir3" ] |
| 458 | [scip-shell system . . `[`. -f "link1" ] |
| 459 | [scip-shell system . . `[`. ! -e "link2" ] |
| 460 | assert_clean_index |
| 461 | ) |
| 462 | end_test |
| 463 | |
| 464 | begin_test "pull: skip file symlink conflicts" |
| 465 | ( |
| 466 | set -e |
| 467 | |
| 468 | skip_if_symlinks_unsupported |
| 469 | |
| 470 | reponame="pull-skip-file-symlink-conflicts" |
| 471 | setup_remote_repo "$reponame" |
| 472 | clone_repo "$reponame" "$reponame" |
| 473 | |
| 474 | gitscip-shell system . . git. lfs track "*.dat" |
| 475 | |
| 476 | contents="a" |
| 477 | contents_oid="$(calc_oid "$contents")" |
| 478 | mkdirscip-shell system . . mkdir. -p dir1/dir2/dir3 |
| 479 | printfscip-shell system . . printf. "%s" "$contents" >a.dat |
| 480 | printfscip-shell system . . printf. "%s" "$contents" >dir1/dir2/dir3/a.dat |
| 481 | |
| 482 | gitscip-shell system . . git. add .gitattributes a.dat dir1 |
| 483 | gitscip-shell system . . git. commit -m "initial commit" |
| 484 | |
| 485 | gitscip-shell system . . git. push origin main |
| 486 | assert_server_object "$reponame" "$contents_oid" |
| 487 | |
| 488 | cd .. |
| 489 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. clone "$GITSERVER/$reponame" "${reponame}-assert" |
| 490 | |
| 491 | cd "${reponame}-assert" |
| 492 | refute_local_object "$contents_oid" 1 |
| 493 | |
| 494 | # test with symlinks to pointer files |
| 495 | rmscip-shell system . . rm. -rf a.dat dir1/dir2/dir3/a.dat ../link* |
| 496 | contents_pointer="$(gitscip-shell system . . git. cat-file -p ":a.dat")" |
| 497 | printfscip-shell system . . printf. "%s" "$contents_pointer" >../link1 |
| 498 | printfscip-shell system . . printf. "%s" "$contents_pointer" >../link2 |
| 499 | lnscip-shell system . . ln. -s ../link1 a.dat |
| 500 | lnscip-shell system . . ln. -s ../../../../link2 dir1/dir2/dir3/a.dat |
| 501 | |
| 502 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 503 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 504 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 505 | exit 1 |
| 506 | fi |
| 507 | grepscip-shell system . . grep. '"a\.dat": not a regular file' pull.log |
| 508 | grepscip-shell system . . grep. '"dir1/dir2/dir3/a\.dat": not a regular file' pull.log |
| 509 | |
| 510 | assert_local_object "$contents_oid" 1 |
| 511 | |
| 512 | [scip-shell system . . `[`. -L "a.dat" ] |
| 513 | [scip-shell system . . `[`. -L "dir1/dir2/dir3/a.dat" ] |
| 514 | [scip-shell system . . `[`. -f "../link1" ] |
| 515 | [scip-shell system . . `[`. "$contents_pointer" = "$(catscip-shell system . . cat. ../link1)" ] |
| 516 | [scip-shell system . . `[`. -f "../link2" ] |
| 517 | [scip-shell system . . `[`. "$contents_pointer" = "$(catscip-shell system . . cat. ../link2)" ] |
| 518 | assert_clean_index |
| 519 | |
| 520 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 521 | |
| 522 | rmscip-shell system . . rm. -rf a.dat dir1/dir2/dir3/a.dat link* |
| 523 | printfscip-shell system . . printf. "%s" "$contents_pointer" >link1 |
| 524 | printfscip-shell system . . printf. "%s" "$contents_pointer" >link2 |
| 525 | lnscip-shell system . . ln. -s link1 a.dat |
| 526 | lnscip-shell system . . ln. -s ../../../link2 dir1/dir2/dir3/a.dat |
| 527 | |
| 528 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 529 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 530 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 531 | exit 1 |
| 532 | fi |
| 533 | grepscip-shell system . . grep. '"a\.dat": not a regular file' pull.log |
| 534 | grepscip-shell system . . grep. '"dir1/dir2/dir3/a\.dat": not a regular file' pull.log |
| 535 | |
| 536 | assert_local_object "$contents_oid" 1 |
| 537 | |
| 538 | [scip-shell system . . `[`. -L "a.dat" ] |
| 539 | [scip-shell system . . `[`. -L "dir1/dir2/dir3/a.dat" ] |
| 540 | [scip-shell system . . `[`. -f "link1" ] |
| 541 | [scip-shell system . . `[`. "$contents_pointer" = "$(catscip-shell system . . cat. link1)" ] |
| 542 | [scip-shell system . . `[`. -f "link2" ] |
| 543 | [scip-shell system . . `[`. "$contents_pointer" = "$(catscip-shell system . . cat. link2)" ] |
| 544 | assert_clean_index |
| 545 | |
| 546 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 547 | |
| 548 | pushd dir1/dir2 |
| 549 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 550 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 551 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 552 | exit 1 |
| 553 | fi |
| 554 | grepscip-shell system . . grep. '"a\.dat": not a regular file' pull.log |
| 555 | grepscip-shell system . . grep. '"dir1/dir2/dir3/a\.dat": not a regular file' pull.log |
| 556 | popd |
| 557 | |
| 558 | assert_local_object "$contents_oid" 1 |
| 559 | |
| 560 | [scip-shell system . . `[`. -L "a.dat" ] |
| 561 | [scip-shell system . . `[`. -L "dir1/dir2/dir3/a.dat" ] |
| 562 | [scip-shell system . . `[`. -f "link1" ] |
| 563 | [scip-shell system . . `[`. "$contents_pointer" = "$(catscip-shell system . . cat. link1)" ] |
| 564 | [scip-shell system . . `[`. -f "link2" ] |
| 565 | [scip-shell system . . `[`. "$contents_pointer" = "$(catscip-shell system . . cat. link2)" ] |
| 566 | assert_clean_index |
| 567 | |
| 568 | # test with symlink to directory and dangling symlink |
| 569 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 570 | |
| 571 | rmscip-shell system . . rm. -rf a.dat dir1/dir2/dir3/a.dat ../link* |
| 572 | mkdirscip-shell system . . mkdir. ../link1 |
| 573 | lnscip-shell system . . ln. -s ../link1 a.dat |
| 574 | lnscip-shell system . . ln. -s ../../../../link2 dir1/dir2/dir3/a.dat |
| 575 | |
| 576 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 577 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 578 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 579 | exit 1 |
| 580 | fi |
| 581 | grepscip-shell system . . grep. '"a\.dat": not a regular file' pull.log |
| 582 | grepscip-shell system . . grep. '"dir1/dir2/dir3/a\.dat": not a regular file' pull.log |
| 583 | |
| 584 | assert_local_object "$contents_oid" 1 |
| 585 | |
| 586 | [scip-shell system . . `[`. -L "a.dat" ] |
| 587 | [scip-shell system . . `[`. -L "dir1/dir2/dir3/a.dat" ] |
| 588 | [scip-shell system . . `[`. -d "../link1" ] |
| 589 | [scip-shell system . . `[`. ! -e "../link2" ] |
| 590 | assert_clean_index |
| 591 | |
| 592 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 593 | |
| 594 | rmscip-shell system . . rm. -rf a.dat dir1/dir2/dir3/a.dat link* |
| 595 | mkdirscip-shell system . . mkdir. link1 |
| 596 | lnscip-shell system . . ln. -s link1 a.dat |
| 597 | lnscip-shell system . . ln. -s ../../../link2 dir1/dir2/dir3/a.dat |
| 598 | |
| 599 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 600 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 601 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 602 | exit 1 |
| 603 | fi |
| 604 | grepscip-shell system . . grep. '"a\.dat": not a regular file' pull.log |
| 605 | grepscip-shell system . . grep. '"dir1/dir2/dir3/a\.dat": not a regular file' pull.log |
| 606 | |
| 607 | assert_local_object "$contents_oid" 1 |
| 608 | |
| 609 | [scip-shell system . . `[`. -L "a.dat" ] |
| 610 | [scip-shell system . . `[`. -L "dir1/dir2/dir3/a.dat" ] |
| 611 | [scip-shell system . . `[`. -d "link1" ] |
| 612 | [scip-shell system . . `[`. ! -e "link2" ] |
| 613 | assert_clean_index |
| 614 | |
| 615 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 616 | |
| 617 | pushd dir1/dir2 |
| 618 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 619 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 620 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 621 | exit 1 |
| 622 | fi |
| 623 | grepscip-shell system . . grep. '"a\.dat": not a regular file' pull.log |
| 624 | grepscip-shell system . . grep. '"dir1/dir2/dir3/a\.dat": not a regular file' pull.log |
| 625 | popd |
| 626 | |
| 627 | assert_local_object "$contents_oid" 1 |
| 628 | |
| 629 | [scip-shell system . . `[`. -L "a.dat" ] |
| 630 | [scip-shell system . . `[`. -L "dir1/dir2/dir3/a.dat" ] |
| 631 | [scip-shell system . . `[`. -d "link1" ] |
| 632 | [scip-shell system . . `[`. ! -e "link2" ] |
| 633 | assert_clean_index |
| 634 | ) |
| 635 | end_test |
| 636 | |
| 637 | # This test applies to case-preserving but case-insensitive filesystems, |
| 638 | # such as APFS and NTFS when in their default configurations. |
| 639 | # On case-sensitive filesystems this test has no particular value and |
| 640 | # should always pass. |
| 641 | begin_test "pull: skip case-based symlink conflicts" |
| 642 | ( |
| 643 | set -e |
| 644 | |
| 645 | skip_if_symlinks_unsupported |
| 646 | |
| 647 | # Only test with Git version 2.20.0 as it introduced detection of |
| 648 | # case-insensitive filesystems to the "git clone" command, which the |
| 649 | # test depends on to determine the filesystem type. |
| 650 | ensure_git_version_isnt "$VERSION_LOWER" "2.20.0" |
| 651 | |
| 652 | reponame="pull-skip-case-symlink-conflicts" |
| 653 | setup_remote_repo "$reponame" |
| 654 | clone_repo "$reponame" "$reponame" |
| 655 | |
| 656 | mkdirscip-shell system . . mkdir. dir1 |
| 657 | lnscip-shell system . . ln. -s ../link1 A.dat |
| 658 | lnscip-shell system . . ln. -s ../../link2 dir1/a.dat |
| 659 | lnscip-shell system . . ln. -s ../link3 DIR3 |
| 660 | lnscip-shell system . . ln. -s ../../link4 dir1/dir2 |
| 661 | |
| 662 | gitscip-shell system . . git. add A.dat dir1 DIR3 |
| 663 | gitscip-shell system . . git. commit -m "initial commit" |
| 664 | |
| 665 | rmscip-shell system . . rm. A.dat dir1/* DIR3 |
| 666 | |
| 667 | echoscip-shell system . . echo. "*.dat filter=lfs diff=lfs merge=lfs -text" >.gitattributes |
| 668 | |
| 669 | contents="a" |
| 670 | contents_oid="$(calc_oid "$contents")" |
| 671 | mkdirscip-shell system . . mkdir. dir3 dir1/DIR2 |
| 672 | printfscip-shell system . . printf. "%s" "$contents" >a.dat |
| 673 | printfscip-shell system . . printf. "%s" "$contents" >dir1/A.dat |
| 674 | printfscip-shell system . . printf. "%s" "$contents" >dir3/a.dat |
| 675 | printfscip-shell system . . printf. "%s" "$contents" >dir1/DIR2/a.dat |
| 676 | |
| 677 | gitscip-shell system . . git. -c core.ignoreCase=false add .gitattributes a.dat dir1/A.dat \ |
| 678 | dir3/a.dat dir1/DIR2/a.dat |
| 679 | gitscip-shell system . . git. commit -m "case-conflicting commit" |
| 680 | |
| 681 | gitscip-shell system . . git. push origin main |
| 682 | assert_server_object "$reponame" "$contents_oid" |
| 683 | |
| 684 | cd .. |
| 685 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. clone "$GITSERVER/$reponame" "${reponame}-assert" 2>&1 | teescip-shell system . . tee. clone.log |
| 686 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 687 | echoscip-shell system . . echo. >&2 "fatal: expected clone to succeed ..." |
| 688 | exit 1 |
| 689 | fi |
| 690 | collision="$(grepscip-shell system . . grep. -c "collided" clone.log)" || truescip-shell system . . true. |
| 691 | |
| 692 | cd "${reponame}-assert" |
| 693 | refute_local_object "$contents_oid" 1 |
| 694 | |
| 695 | rmscip-shell system . . rm. -rf *.dat dir1 *3 ../link* |
| 696 | mkdirscip-shell system . . mkdir. ../link3 ../link4 |
| 697 | |
| 698 | gitscip-shell system . . git. lfs pull |
| 699 | |
| 700 | assert_local_object "$contents_oid" 1 |
| 701 | |
| 702 | [scip-shell system . . `[`. -f "a.dat" ] |
| 703 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "a.dat")" ] |
| 704 | [scip-shell system . . `[`. -f "dir1/A.dat" ] |
| 705 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "dir1/A.dat")" ] |
| 706 | [scip-shell system . . `[`. -f "dir3/a.dat" ] |
| 707 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "dir3/a.dat")" ] |
| 708 | [scip-shell system . . `[`. -f "dir1/DIR2/a.dat" ] |
| 709 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "dir1/DIR2/a.dat")" ] |
| 710 | [scip-shell system . . `[`. ! -e "../link1" ] |
| 711 | [scip-shell system . . `[`. ! -e "../link2" ] |
| 712 | [scip-shell system . . `[`. ! -e "../link3/a.dat" ] |
| 713 | [scip-shell system . . `[`. ! -e "../link4/a.dat" ] |
| 714 | assert_clean_index |
| 715 | |
| 716 | rmscip-shell system . . rm. -rf a.dat dir1/A.dat dir3 dir1/DIR2 |
| 717 | gitscip-shell system . . git. checkout -- A.dat dir1/a.dat DIR3 dir1/dir2 |
| 718 | |
| 719 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 720 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 721 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 722 | exit 1 |
| 723 | fi |
| 724 | if [scip-shell system . . `[`. "$collision" -gt "0" ]; then |
| 725 | # case-insensitive filesystem |
| 726 | grepscip-shell system . . grep. '"a\.dat": not a regular file' pull.log |
| 727 | grepscip-shell system . . grep. '"dir1/A\.dat": not a regular file' pull.log |
| 728 | grepscip-shell system . . grep. '"dir3/a\.dat": not a directory' pull.log |
| 729 | grepscip-shell system . . grep. '"dir1/DIR2/a\.dat": not a directory' pull.log |
| 730 | [scip-shell system . . `[`. 0 -eq "$(grepscip-shell system . . grep. -c "is beyond a symbolic link" pull.log)" ] |
| 731 | fi |
| 732 | |
| 733 | if [scip-shell system . . `[`. "$collision" -eq "0" ]; then |
| 734 | # case-sensitive filesystem |
| 735 | [scip-shell system . . `[`. -f "a.dat" ] |
| 736 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "a.dat")" ] |
| 737 | [scip-shell system . . `[`. -f "dir1/A.dat" ] |
| 738 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "dir1/A.dat")" ] |
| 739 | [scip-shell system . . `[`. -f "dir3/a.dat" ] |
| 740 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "dir3/a.dat")" ] |
| 741 | [scip-shell system . . `[`. -f "dir1/DIR2/a.dat" ] |
| 742 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "dir1/DIR2/a.dat")" ] |
| 743 | else |
| 744 | # case-insensitive filesystem |
| 745 | [scip-shell system . . `[`. -L "a.dat" ] |
| 746 | [scip-shell system . . `[`. -L "dir1/A.dat" ] |
| 747 | [scip-shell system . . `[`. -L "dir3" ] |
| 748 | [scip-shell system . . `[`. -L "dir1/DIR2" ] |
| 749 | fi |
| 750 | [scip-shell system . . `[`. ! -e "../link1" ] |
| 751 | [scip-shell system . . `[`. ! -e "../link2" ] |
| 752 | [scip-shell system . . `[`. ! -e "../link3/a.dat" ] |
| 753 | [scip-shell system . . `[`. ! -e "../link4/a.dat" ] |
| 754 | assert_clean_index |
| 755 | ) |
| 756 | end_test |
| 757 | |
| 758 | begin_test "pull: skip changed files" |
| 759 | ( |
| 760 | set -e |
| 761 | |
| 762 | reponame="pull-skip-changed-files" |
| 763 | setup_remote_repo "$reponame" |
| 764 | clone_repo "$reponame" "$reponame" |
| 765 | |
| 766 | gitscip-shell system . . git. lfs track "*.dat" |
| 767 | |
| 768 | contents="a" |
| 769 | contents_oid="$(calc_oid "$contents")" |
| 770 | printfscip-shell system . . printf. "%s" "$contents" >a.dat |
| 771 | |
| 772 | gitscip-shell system . . git. add .gitattributes a.dat |
| 773 | gitscip-shell system . . git. commit -m "initial commit" |
| 774 | |
| 775 | gitscip-shell system . . git. push origin main |
| 776 | assert_server_object "$reponame" "$contents_oid" |
| 777 | |
| 778 | cd .. |
| 779 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. clone "$GITSERVER/$reponame" "${reponame}-assert" |
| 780 | |
| 781 | cd "${reponame}-assert" |
| 782 | refute_local_object "$contents_oid" 1 |
| 783 | |
| 784 | contents_new="$contents +extra" |
| 785 | printfscip-shell system . . printf. "%s" "$contents_new" >a.dat |
| 786 | |
| 787 | gitscip-shell system . . git. lfs pull |
| 788 | assert_local_object "$contents_oid" 1 |
| 789 | |
| 790 | [scip-shell system . . `[`. "$contents_new" = "$(catscip-shell system . . cat. a.dat)" ] |
| 791 | assert_clean_index |
| 792 | |
| 793 | rmscip-shell system . . rm. a.dat |
| 794 | mkdirscip-shell system . . mkdir. a.dat |
| 795 | |
| 796 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 797 | gitscip-shell system . . git. lfs pull |
| 798 | assert_local_object "$contents_oid" 1 |
| 799 | |
| 800 | [scip-shell system . . `[`. -d "a.dat" ] |
| 801 | assert_clean_index |
| 802 | |
| 803 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 804 | |
| 805 | pushd a.dat |
| 806 | gitscip-shell system . . git. lfs pull |
| 807 | popd |
| 808 | |
| 809 | assert_local_object "$contents_oid" 1 |
| 810 | |
| 811 | [scip-shell system . . `[`. -d "a.dat" ] |
| 812 | assert_clean_index |
| 813 | ) |
| 814 | end_test |
| 815 | |
| 816 | begin_test "pull: break hard links to existing files" |
| 817 | ( |
| 818 | set -e |
| 819 | |
| 820 | reponame="pull-break-file-hardlinks" |
| 821 | setup_remote_repo "$reponame" |
| 822 | clone_repo "$reponame" "$reponame" |
| 823 | |
| 824 | gitscip-shell system . . git. lfs track "*.dat" |
| 825 | |
| 826 | contents="a" |
| 827 | contents_oid="$(calc_oid "$contents")" |
| 828 | mkdirscip-shell system . . mkdir. -p dir1/dir2/dir3 |
| 829 | printfscip-shell system . . printf. "%s" "$contents" >a.dat |
| 830 | printfscip-shell system . . printf. "%s" "$contents" >dir1/dir2/dir3/a.dat |
| 831 | |
| 832 | gitscip-shell system . . git. add .gitattributes a.dat dir1 |
| 833 | gitscip-shell system . . git. commit -m "initial commit" |
| 834 | |
| 835 | gitscip-shell system . . git. push origin main |
| 836 | assert_server_object "$reponame" "$contents_oid" |
| 837 | |
| 838 | cd .. |
| 839 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. clone "$GITSERVER/$reponame" "${reponame}-assert" |
| 840 | |
| 841 | cd "${reponame}-assert" |
| 842 | refute_local_object "$contents_oid" 1 |
| 843 | |
| 844 | rmscip-shell system . . rm. -f a.dat dir1/dir2/dir3/a.dat ../link |
| 845 | pointer="$(gitscip-shell system . . git. cat-file -p ":a.dat")" |
| 846 | echoscip-shell system . . echo. "$pointer" >../link |
| 847 | lnscip-shell system . . ln. ../link a.dat |
| 848 | lnscip-shell system . . ln. ../link dir1/dir2/dir3/a.dat |
| 849 | |
| 850 | gitscip-shell system . . git. lfs pull |
| 851 | assert_local_object "$contents_oid" 1 |
| 852 | |
| 853 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. a.dat)" ] |
| 854 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. dir1/dir2/dir3/a.dat)" ] |
| 855 | [scip-shell system . . `[`. "$pointer" = "$(catscip-shell system . . cat. ../link)" ] |
| 856 | assert_clean_status |
| 857 | |
| 858 | rmscip-shell system . . rm. a.dat dir1/dir2/dir3/a.dat |
| 859 | lnscip-shell system . . ln. ../link a.dat |
| 860 | lnscip-shell system . . ln. ../link dir1/dir2/dir3/a.dat |
| 861 | |
| 862 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 863 | |
| 864 | pushd dir1/dir2 |
| 865 | gitscip-shell system . . git. lfs pull |
| 866 | popd |
| 867 | |
| 868 | assert_local_object "$contents_oid" 1 |
| 869 | |
| 870 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. a.dat)" ] |
| 871 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. dir1/dir2/dir3/a.dat)" ] |
| 872 | [scip-shell system . . `[`. "$pointer" = "$(catscip-shell system . . cat. ../link)" ] |
| 873 | assert_clean_status |
| 874 | ) |
| 875 | end_test |
| 876 | |
| 877 | begin_test "pull without clean filter" |
| 878 | ( |
| 879 | set -e |
| 880 | |
| 881 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. clone $GITSERVER/t-pull no-clean |
| 882 | cd no-clean |
| 883 | gitscip-shell system . . git. lfs uninstall |
| 884 | gitscip-shell system . . git. config --list > config.txt |
| 885 | grepscip-shell system . . grep. "filter.lfs.clean" config.txt && { |
| 886 | echoscip-shell system . . echo. "clean filter still configured:" |
| 887 | catscip-shell system . . cat. config.txt |
| 888 | exit 1 |
| 889 | } |
| 890 | |
| 891 | contents="a" |
| 892 | contents_oid=$(calc_oid "$contents") |
| 893 | |
| 894 | # LFS object not downloaded, pointer in working directory |
| 895 | grepscip-shell system . . grep. "$contents_oid" a.dat || { |
| 896 | echoscip-shell system . . echo. "a.dat not $contents_oid" |
| 897 | lsscip-shell system . . ls. -al |
| 898 | catscip-shell system . . cat. a.dat |
| 899 | exit 1 |
| 900 | } |
| 901 | assert_local_object "$contents_oid" |
| 902 | |
| 903 | gitscip-shell system . . git. lfs pull | teescip-shell system . . tee. pull.txt |
| 904 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 905 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 906 | exit 1 |
| 907 | fi |
| 908 | grepscip-shell system . . grep. "Git LFS is not installed" pull.txt |
| 909 | echoscip-shell system . . echo. "pulled!" |
| 910 | |
| 911 | # LFS object downloaded, pointer unchanged |
| 912 | grepscip-shell system . . grep. "$contents_oid" a.dat || { |
| 913 | echoscip-shell system . . echo. "a.dat not $contents_oid" |
| 914 | lsscip-shell system . . ls. -al |
| 915 | catscip-shell system . . cat. a.dat |
| 916 | exit 1 |
| 917 | } |
| 918 | assert_local_object "$contents_oid" 1 |
| 919 | ) |
| 920 | end_test |
| 921 | |
| 922 | begin_test "pull with raw remote url" |
| 923 | ( |
| 924 | set -e |
| 925 | mkdirscip-shell system . . mkdir. raw |
| 926 | cd raw |
| 927 | gitscip-shell system . . git. init |
| 928 | gitscip-shell system . . git. lfs install --local --skip-smudge |
| 929 | |
| 930 | gitscip-shell system . . git. remote add origin $GITSERVER/t-pull |
| 931 | gitscip-shell system . . git. pull origin main |
| 932 | |
| 933 | contents="a" |
| 934 | contents_oid=$(calc_oid "$contents") |
| 935 | |
| 936 | # LFS object not downloaded, pointer in working directory |
| 937 | refute_local_object "$contents_oid" |
| 938 | grepscip-shell system . . grep. "$contents_oid" a.dat |
| 939 | |
| 940 | gitscip-shell system . . git. lfs pull "$GITSERVER/t-pull" |
| 941 | echoscip-shell system . . echo. "pulled!" |
| 942 | |
| 943 | # LFS object downloaded and in working directory |
| 944 | assert_local_object "$contents_oid" 1 |
| 945 | [scip-shell system . . `[`. 0 -eq "$(grepscip-shell system . . grep. -c "$contents_oid" a.dat)" ] |
| 946 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 947 | ) |
| 948 | end_test |
| 949 | |
| 950 | begin_test "pull with multiple remotes" |
| 951 | ( |
| 952 | set -e |
| 953 | mkdirscip-shell system . . mkdir. multiple |
| 954 | cd multiple |
| 955 | gitscip-shell system . . git. init |
| 956 | gitscip-shell system . . git. lfs install --local --skip-smudge |
| 957 | |
| 958 | gitscip-shell system . . git. remote add origin "$GITSERVER/t-pull" |
| 959 | gitscip-shell system . . git. remote add bad-remote "invalid-url" |
| 960 | gitscip-shell system . . git. pull origin main |
| 961 | |
| 962 | contents="a" |
| 963 | contents_oid=$(calc_oid "$contents") |
| 964 | |
| 965 | # LFS object not downloaded, pointer in working directory |
| 966 | refute_local_object "$contents_oid" |
| 967 | grepscip-shell system . . grep. "$contents_oid" a.dat |
| 968 | |
| 969 | # pull should default to origin instead of bad-remote |
| 970 | gitscip-shell system . . git. lfs pull |
| 971 | echoscip-shell system . . echo. "pulled!" |
| 972 | |
| 973 | # LFS object downloaded and in working directory |
| 974 | assert_local_object "$contents_oid" 1 |
| 975 | [scip-shell system . . `[`. 0 -eq "$(grepscip-shell system . . grep. -c "$contents_oid" a.dat)" ] |
| 976 | [scip-shell system . . `[`. "a" = "$(catscip-shell system . . cat. a.dat)" ] |
| 977 | ) |
| 978 | end_test |
| 979 | |
| 980 | begin_test "pull with invalid insteadof" |
| 981 | ( |
| 982 | set -e |
| 983 | mkdirscip-shell system . . mkdir. insteadof |
| 984 | cd insteadof |
| 985 | gitscip-shell system . . git. init |
| 986 | gitscip-shell system . . git. lfs install --local --skip-smudge |
| 987 | |
| 988 | gitscip-shell system . . git. remote add origin "$GITSERVER/t-pull" |
| 989 | gitscip-shell system . . git. pull origin main |
| 990 | |
| 991 | # set insteadOf to rewrite the href of downloading LFS object. |
| 992 | gitscip-shell system . . git. config url."$GITSERVER/storage/invalid".insteadOf "$GITSERVER/storage/" |
| 993 | # Enable href rewriting explicitly. |
| 994 | gitscip-shell system . . git. config lfs.transfer.enablehrefrewrite true |
| 995 | |
| 996 | set +e |
| 997 | gitscip-shell system . . git. lfs pull > pull.log 2>&1 |
| 998 | res=$? |
| 999 | |
| 1000 | set -e |
| 1001 | [scip-shell system . . `[`. "$res" = "2" ] |
| 1002 | |
| 1003 | # check rewritten href is used to download LFS object. |
| 1004 | grepscip-shell system . . grep. "LFS: Repository or object not found: $GITSERVER/storage/invalid" pull.log |
| 1005 | |
| 1006 | # lfs-pull succeed after unsetting enableHrefRewrite config |
| 1007 | gitscip-shell system . . git. config --unset lfs.transfer.enablehrefrewrite |
| 1008 | gitscip-shell system . . git. lfs pull |
| 1009 | ) |
| 1010 | end_test |
| 1011 | |
| 1012 | begin_test "pull with merge conflict" |
| 1013 | ( |
| 1014 | set -e |
| 1015 | gitscip-shell system . . git. init pull-merge-conflict |
| 1016 | cd pull-merge-conflict |
| 1017 | |
| 1018 | gitscip-shell system . . git. lfs track "*.bin" |
| 1019 | gitscip-shell system . . git. add . |
| 1020 | gitscip-shell system . . git. commit -m 'gitattributes' |
| 1021 | printfscip-shell system . . printf. abc > abc.bin |
| 1022 | gitscip-shell system . . git. add . |
| 1023 | gitscip-shell system . . git. commit -m 'abc' |
| 1024 | |
| 1025 | gitscip-shell system . . git. checkout -b def |
| 1026 | printfscip-shell system . . printf. def > abc.bin |
| 1027 | gitscip-shell system . . git. add . |
| 1028 | gitscip-shell system . . git. commit -m 'def' |
| 1029 | |
| 1030 | gitscip-shell system . . git. checkout main |
| 1031 | printfscip-shell system . . printf. ghi > abc.bin |
| 1032 | gitscip-shell system . . git. add . |
| 1033 | gitscip-shell system . . git. commit -m 'ghi' |
| 1034 | |
| 1035 | # This will exit nonzero because of the merge conflict. |
| 1036 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. merge def || truescip-shell system . . true. |
| 1037 | gitscip-shell system . . git. lfs pull > pull.log 2>&1 |
| 1038 | [scip-shell system . . `[`. ! -s pull.log ] |
| 1039 | ) |
| 1040 | end_test |
| 1041 | |
| 1042 | begin_test "pull: with missing object" |
| 1043 | ( |
| 1044 | set -e |
| 1045 | |
| 1046 | # this clone is setup in the first test in this file |
| 1047 | cd clone |
| 1048 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 1049 | rmscip-shell system . . rm. a.dat |
| 1050 | |
| 1051 | contents_oid=$(calc_oid "a") |
| 1052 | reponame="$(basenamescip-shell system . . basename. "$0" ".sh")" |
| 1053 | delete_server_object "$reponame" "$contents_oid" |
| 1054 | refute_server_object "$reponame" "$contents_oid" |
| 1055 | |
| 1056 | # should return non-zero, but should also download all the other valid files too |
| 1057 | gitscip-shell system . . git. config branch.main.remote origin |
| 1058 | gitscip-shell system . . git. config branch.main.merge refs/heads/main |
| 1059 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 1060 | pull_exit="${PIPESTATUS[0]}" |
| 1061 | [scip-shell system . . `[`. "$pull_exit" != "0" ] |
| 1062 | |
| 1063 | grepscip-shell system . . grep. "$contents_oid does not exist" pull.log |
| 1064 | |
| 1065 | contents2_oid=$(calc_oid "A") |
| 1066 | assert_local_object "$contents2_oid" 1 |
| 1067 | refute_local_object "$contents_oid" |
| 1068 | ) |
| 1069 | end_test |
| 1070 | |
| 1071 | begin_test "pull: outside git repository" |
| 1072 | ( |
| 1073 | set +e |
| 1074 | gitscip-shell system . . git. lfs pull 2>&1 > pull.log |
| 1075 | res=$? |
| 1076 | |
| 1077 | set -e |
| 1078 | if [scip-shell system . . `[`. "$res" = "0" ]; then |
| 1079 | echoscip-shell system . . echo. "Passes because $GIT_LFS_TEST_DIR is unset." |
| 1080 | exit 0 |
| 1081 | fi |
| 1082 | [scip-shell system . . `[`. "$res" = "128" ] |
| 1083 | grepscip-shell system . . grep. "Not in a Git repository" pull.log |
| 1084 | ) |
| 1085 | end_test |
| 1086 | |
| 1087 | begin_test "pull: read-only directory" |
| 1088 | ( |
| 1089 | set -e |
| 1090 | |
| 1091 | skip_if_root_or_admin "$test_description" |
| 1092 | |
| 1093 | reponame="pull-read-only" |
| 1094 | setup_remote_repo "$reponame" |
| 1095 | clone_repo "$reponame" "$reponame" |
| 1096 | |
| 1097 | gitscip-shell system . . git. lfs track "*.bin" |
| 1098 | |
| 1099 | contents="a" |
| 1100 | contents_oid=$(calc_oid "$contents") |
| 1101 | mkdirscip-shell system . . mkdir. dir |
| 1102 | printfscip-shell system . . printf. "%s" "$contents" > dir/a.bin |
| 1103 | |
| 1104 | gitscip-shell system . . git. add .gitattributes dir/a.bin |
| 1105 | gitscip-shell system . . git. commit -m "add dir/a.bin" |
| 1106 | |
| 1107 | gitscip-shell system . . git. push origin main |
| 1108 | |
| 1109 | assert_server_object "$reponame" "$contents_oid" |
| 1110 | |
| 1111 | rmscip-shell system . . rm. dir/a.bin |
| 1112 | delete_local_object "$contents_oid" |
| 1113 | |
| 1114 | if [scip-shell system . . `[`. "$IS_WINDOWS" -eq 1 ]; then |
| 1115 | icacls dir /inheritance:rscip-shell filesystem . . `/inheritance:r`. |
| 1116 | icacls dir /grant:rscip-shell filesystem . . `/grant:r`. Everyone:R |
| 1117 | else |
| 1118 | chmodscip-shell system . . chmod. a-w dir |
| 1119 | fi |
| 1120 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 1121 | # Note that although the pull command should log an error, at present |
| 1122 | # we still expect a zero exit code. |
| 1123 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 1124 | echoscip-shell system . . echo. >&2 "fatal: expected 'git lfs pull' to succeed ..." |
| 1125 | exit 1 |
| 1126 | fi |
| 1127 | |
| 1128 | assert_local_object "$contents_oid" 1 |
| 1129 | |
| 1130 | [scip-shell system . . `[`. ! -e dir/a.bin ] |
| 1131 | |
| 1132 | grepscip-shell system . . grep. 'could not check out "dir/a.bin"' pull.log |
| 1133 | grepscip-shell system . . grep. 'could not create working directory file' pull.log |
| 1134 | grepscip-shell system . . grep. 'permission denied' pull.log |
| 1135 | ) |
| 1136 | end_test |
| 1137 | |
| 1138 | begin_test "pull: read-only file" |
| 1139 | ( |
| 1140 | set -e |
| 1141 | |
| 1142 | reponame="pull-locked" |
| 1143 | filename="a.txt" |
| 1144 | |
| 1145 | setup_remote_repo_with_file "$reponame" "$filename" |
| 1146 | contents_oid="$(calc_oid_file "$filename")" |
| 1147 | |
| 1148 | pushd "$TRASHDIR" > /dev/nullscip-shell filesystem . . `/dev/null`. |
| 1149 | GIT_LFS_SKIP_SMUDGE=1 clone_repo "$reponame" "${reponame}-assert" |
| 1150 | |
| 1151 | chmodscip-shell system . . chmod. a-w "$filename" |
| 1152 | |
| 1153 | refute_file_writeable "$filename" |
| 1154 | assert_pointer "refs/heads/main" "$filename" "$contents_oid" 6 |
| 1155 | |
| 1156 | gitscip-shell system . . git. lfs pull |
| 1157 | |
| 1158 | refute_file_writeable "$filename" |
| 1159 | [scip-shell system . . `[`. "$filename" = "$(catscip-shell system . . cat. "$filename")" ] |
| 1160 | popd > /dev/nullscip-shell filesystem . . `/dev/null`. |
| 1161 | ) |
| 1162 | end_test |
| 1163 | |
| 1164 | begin_test "pull with empty file doesn't modify mtime" |
| 1165 | ( |
| 1166 | set -e |
| 1167 | gitscip-shell system . . git. init pull-empty-file |
| 1168 | cd pull-empty-file |
| 1169 | |
| 1170 | gitscip-shell system . . git. lfs track "*.bin" |
| 1171 | gitscip-shell system . . git. add . |
| 1172 | gitscip-shell system . . git. commit -m 'gitattributes' |
| 1173 | printfscip-shell system . . printf. abc > abc.bin |
| 1174 | gitscip-shell system . . git. add . |
| 1175 | gitscip-shell system . . git. commit -m 'abc' |
| 1176 | |
| 1177 | touchscip-shell system . . touch. foo.bin |
| 1178 | lfstest-nanomtime foo.bin >foo.mtime |
| 1179 | |
| 1180 | # This isn't necessary, but it takes a few cycles to make sure that our |
| 1181 | # timestamp changes. |
| 1182 | gitscip-shell system . . git. add foo.bin |
| 1183 | gitscip-shell system . . git. commit -m 'foo' |
| 1184 | |
| 1185 | gitscip-shell system . . git. lfs pull |
| 1186 | lfstest-nanomtime foo.bin >foo.mtime2 |
| 1187 | diffscip-shell system . . diff. -u foo.mtime foo.mtime2 |
| 1188 | ) |
| 1189 | end_test |
| 1190 | |
| 1191 | begin_test "pull: bare repository" |
| 1192 | ( |
| 1193 | set -e |
| 1194 | |
| 1195 | reponame="pull-bare" |
| 1196 | setup_remote_repo "$reponame" |
| 1197 | clone_repo "$reponame" "$reponame" |
| 1198 | |
| 1199 | gitscip-shell system . . git. lfs track "*.dat" |
| 1200 | |
| 1201 | contents="a" |
| 1202 | contents_oid="$(calc_oid "$contents")" |
| 1203 | printfscip-shell system . . printf. "%s" "$contents" >a.dat |
| 1204 | |
| 1205 | # The "git lfs pull" command should never check out files in a bare |
| 1206 | # repository, either into a directory within the repository or one |
| 1207 | # outside it. To verify this, we add a Git LFS pointer file whose path |
| 1208 | # inside the repository is one which, if it were instead treated as an |
| 1209 | # absolute filesystem path, corresponds to a writable directory. |
| 1210 | # The "git lfs pull" command should not check out files into either |
| 1211 | # this external directory or the bare repository. |
| 1212 | external_dir="$TRASHDIR/${reponame}-external" |
| 1213 | internal_dir="$(printfscip-shell system . . printf. "%s" "$external_dir" | sedscip-shell system . . sed. 's/^\/*//')" |
| 1214 | mkdirscip-shell system . . mkdir. -p "$internal_dir" |
| 1215 | printfscip-shell system . . printf. "%s" "$contents" >"$internal_dir/a.dat" |
| 1216 | |
| 1217 | gitscip-shell system . . git. add .gitattributes a.dat "$internal_dir/a.dat" |
| 1218 | gitscip-shell system . . git. commit -m "initial commit" |
| 1219 | |
| 1220 | gitscip-shell system . . git. push origin main |
| 1221 | assert_server_object "$reponame" "$contents_oid" |
| 1222 | |
| 1223 | cd .. |
| 1224 | gitscip-shell system . . git. clone --bare "$GITSERVER/$reponame" "${reponame}-assert" |
| 1225 | |
| 1226 | cd "${reponame}-assert" |
| 1227 | [scip-shell system . . `[`. ! -e lfs ] |
| 1228 | refute_local_object "$contents_oid" |
| 1229 | |
| 1230 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 1231 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 1232 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 1233 | exit 1 |
| 1234 | fi |
| 1235 | |
| 1236 | # When Git version 2.42.0 or higher is available, the "git lfs pull" |
| 1237 | # command will use the "git ls-files" command rather than the |
| 1238 | # "git ls-tree" command to list files. By default a bare repository |
| 1239 | # lacks an index, so we expect no Git LFS objects to be fetched when |
| 1240 | # "git ls-files" is used because Git v2.42.0 or higher is available. |
| 1241 | gitversion="$(gitscip-shell system . . git. version | cutscip-shell system . . cut. -d" " -f3)" |
| 1242 | set +e |
| 1243 | compare_version "$gitversion" '2.42.0' |
| 1244 | result=$? |
| 1245 | set -e |
| 1246 | if [scip-shell system . . `[`. "$result" -eq "$VERSION_LOWER" ]; then |
| 1247 | grepscip-shell system . . grep. "Downloading LFS objects" pull.log |
| 1248 | |
| 1249 | assert_local_object "$contents_oid" 1 |
| 1250 | else |
| 1251 | grepscip-shell system . . grep. -q "Downloading LFS objects" pull.log && exit 1 |
| 1252 | |
| 1253 | refute_local_object "$contents_oid" |
| 1254 | fi |
| 1255 | |
| 1256 | [scip-shell system . . `[`. ! -e "a.dat" ] |
| 1257 | [scip-shell system . . `[`. ! -e "$internal_dir/a.dat" ] |
| 1258 | [scip-shell system . . `[`. ! -e "$external_dir/a.dat" ] |
| 1259 | |
| 1260 | rmscip-shell system . . rm. -rf lfs/objects |
| 1261 | refute_local_object "$contents_oid" |
| 1262 | |
| 1263 | # When Git version 2.42.0 or higher is available, the "git lfs pull" |
| 1264 | # command will use the "git ls-files" command rather than the |
| 1265 | # "git ls-tree" command to list files. By default a bare repository |
| 1266 | # lacks an index, so we expect no Git LFS objects to be fetched when |
| 1267 | # "git ls-files" is used because Git v2.42.0 or higher is available. |
| 1268 | # |
| 1269 | # Therefore to verify that the "git lfs pull" command never checks out |
| 1270 | # files in a bare repository, we first populate the index with Git LFS |
| 1271 | # pointer files and then retry the command. |
| 1272 | contents_git_oid="$(gitscip-shell system . . git. ls-tree HEAD a.dat | awkscip-shell system . . awk. '{ print $3 }')" |
| 1273 | gitscip-shell system . . git. update-index --add --cacheinfo 100644 "$contents_git_oid" a.dat |
| 1274 | gitscip-shell system . . git. update-index --add --cacheinfo 100644 "$contents_git_oid" "$internal_dir/a.dat" |
| 1275 | |
| 1276 | # When Git version 2.42.0 or higher is available, the "git lfs pull" |
| 1277 | # command will use the "git ls-files" command rather than the |
| 1278 | # "git ls-tree" command to list files, and does so by passing an |
| 1279 | # "attr:filter=lfs" pathspec to the "git ls-files" command so it only |
| 1280 | # lists files which match that filter attribute. |
| 1281 | # |
| 1282 | # In a bare repository, however, the "git ls-files" command will not read |
| 1283 | # attributes from ".gitattributes" files in the index, so by default it |
| 1284 | # will not list any Git LFS pointer files even if those files and the |
| 1285 | # corresponding ".gitattributes" files have been added to the index and |
| 1286 | # the pointer files would otherwise match the "attr:filter=lfs" pathspec. |
| 1287 | # |
| 1288 | # Therefore, instead of adding the ".gitattributes" file to the index, we |
| 1289 | # copy it to "info/attributes" so that the pathspec filter will match our |
| 1290 | # pointer file index entries and they will be listed by the "git ls-files" |
| 1291 | # command. This allows us to verify that with Git v2.42.0 or higher, the |
| 1292 | # "git lfs pull" command will fetch the objects for these pointer files |
| 1293 | # in the index when the command is run in a bare repository. |
| 1294 | # |
| 1295 | # Note that with older versions of Git, the "git lfs pull" command will |
| 1296 | # use the "git ls-tree" command to list the files in the tree referenced |
| 1297 | # by HEAD. The Git LFS objects for any well-formed pointer files found in |
| 1298 | # that list will then be fetched (unless local copies already exist), |
| 1299 | # regardless of whether the pointer files actually match a "filter=lfs" |
| 1300 | # attribute in any ".gitattributes" file in the index, the tree |
| 1301 | # referenced by HEAD, or the current work tree. |
| 1302 | if [scip-shell system . . `[`. "$result" -ne "$VERSION_LOWER" ]; then |
| 1303 | mkdirscip-shell system . . mkdir. -p info |
| 1304 | gitscip-shell system . . git. show HEAD:.gitattributes >info/attributes |
| 1305 | fi |
| 1306 | |
| 1307 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 1308 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 1309 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 1310 | exit 1 |
| 1311 | fi |
| 1312 | grepscip-shell system . . grep. "Downloading LFS objects" pull.log |
| 1313 | |
| 1314 | assert_local_object "$contents_oid" 1 |
| 1315 | |
| 1316 | [scip-shell system . . `[`. ! -e "a.dat" ] |
| 1317 | [scip-shell system . . `[`. ! -e "$internal_dir/a.dat" ] |
| 1318 | [scip-shell system . . `[`. ! -e "$external_dir/a.dat" ] |
| 1319 | ) |
| 1320 | end_test |
| 1321 | |
| 1322 | begin_test "pull with partial clone and sparse checkout and index" |
| 1323 | ( |
| 1324 | set -e |
| 1325 | |
| 1326 | # Only test with Git version 2.25.0 as it introduced the |
| 1327 | # "git sparse-checkout" command. (Note that this test also requires |
| 1328 | # that the "git rev-list" command support the "tree:0" filter, which |
| 1329 | # was introduced with Git version 2.20.0.) |
| 1330 | ensure_git_version_isnt "$VERSION_LOWER" "2.25.0" |
| 1331 | |
| 1332 | reponame="pull-sparse" |
| 1333 | setup_remote_repo "$reponame" |
| 1334 | clone_repo "$reponame" "$reponame" |
| 1335 | |
| 1336 | gitscip-shell system . . git. lfs track "*.dat" |
| 1337 | |
| 1338 | contents1="a" |
| 1339 | contents1_oid=$(calc_oid "$contents1") |
| 1340 | contents2="b" |
| 1341 | contents2_oid=$(calc_oid "$contents2") |
| 1342 | contents3="c" |
| 1343 | contents3_oid=$(calc_oid "$contents3") |
| 1344 | |
| 1345 | mkdirscip-shell system . . mkdir. in-dir out-dir |
| 1346 | printfscip-shell system . . printf. "%s" "$contents1" >a.dat |
| 1347 | printfscip-shell system . . printf. "%s" "$contents2" >in-dir/b.dat |
| 1348 | printfscip-shell system . . printf. "%s" "$contents3" >out-dir/c.dat |
| 1349 | gitscip-shell system . . git. add . |
| 1350 | gitscip-shell system . . git. commit -m "add files" |
| 1351 | |
| 1352 | gitscip-shell system . . git. push origin main |
| 1353 | |
| 1354 | assert_server_object "$reponame" "$contents1_oid" |
| 1355 | assert_server_object "$reponame" "$contents2_oid" |
| 1356 | assert_server_object "$reponame" "$contents3_oid" |
| 1357 | |
| 1358 | # Create a partial clone with a cone-mode sparse checkout of one directory |
| 1359 | # and a sparse index, which is important because otherwise the "git ls-files" |
| 1360 | # command ignores the --sparse option and lists all Git LFS files. |
| 1361 | cd .. |
| 1362 | giscip-shell system . . git.tscip-shell system . . git. clone --filter=tree:0 --depth=1 --no-checkout \ |
| 1363 | "$GITSERVER/$reponame" "${reponame}-partial" |
| 1364 | |
| 1365 | cd "${reponame}-partial" |
| 1366 | gitscip-shell system . . git. sparse-checkout init --cone --sparse-index |
| 1367 | gitscip-shell system . . git. sparse-checkout set "in-dir" |
| 1368 | gitscip-shell system . . git. checkout main |
| 1369 | |
| 1370 | [scip-shell system . . `[`. -d "in-dir" ] |
| 1371 | [scip-shell system . . `[`. ! -e "out-dir" ] |
| 1372 | |
| 1373 | assert_local_object "$contents1_oid" 1 |
| 1374 | assert_local_object "$contents2_oid" 1 |
| 1375 | refute_local_object "$contents3_oid" |
| 1376 | |
| 1377 | gitscip-shell system . . git. lfs pull 2>&1 | teescip-shell system . . tee. pull.log |
| 1378 | if [scip-shell system . . `[`. "0" -ne "${PIPESTATUS[0]}" ]; then |
| 1379 | echoscip-shell system . . echo. >&2 "fatal: expected pull to succeed ..." |
| 1380 | exit 1 |
| 1381 | fi |
| 1382 | |
| 1383 | # When Git version 2.42.0 or higher is available, the "git lfs pull" |
| 1384 | # command will use the "git ls-files" command rather than the |
| 1385 | # "git ls-tree" command to list files. Git v2.42.0 introduced support |
| 1386 | # in the "git ls-files" command for the "objecttype" format option and |
| 1387 | # so Git LFS can use this command to avoid pulling objects outside |
| 1388 | # the sparse cone. Otherwise, all Git LFS objects will be pulled. |
| 1389 | gitversion="$(gitscip-shell system . . git. version | cutscip-shell system . . cut. -d" " -f3)" |
| 1390 | set +e |
| 1391 | compare_version "$gitversion" '2.42.0' |
| 1392 | result=$? |
| 1393 | set -e |
| 1394 | if [scip-shell system . . `[`. "$result" -eq "$VERSION_LOWER" ]; then |
| 1395 | grepscip-shell system . . grep. "Downloading LFS objects" pull.log |
| 1396 | |
| 1397 | [scip-shell system . . `[`. -f "out-dir/c.dat" ] |
| 1398 | [scip-shell system . . `[`. "$contents3" = "$(catscip-shell system . . cat. "out-dir/c.dat")" ] |
| 1399 | |
| 1400 | assert_local_object "$contents3_oid" 1 |
| 1401 | else |
| 1402 | grepscip-shell system . . grep. -q "Downloading LFS objects" pull.log && exit 1 |
| 1403 | |
| 1404 | [scip-shell system . . `[`. ! -e "out-dir" ] |
| 1405 | |
| 1406 | refute_local_object "$contents3_oid" |
| 1407 | fi |
| 1408 | ) |
| 1409 | end_test |
| 1410 | |
| 1411 | begin_test "pull: pointer extension" |
| 1412 | ( |
| 1413 | set -e |
| 1414 | |
| 1415 | reponame="pull-pointer-extension" |
| 1416 | setup_remote_repo "$reponame" |
| 1417 | clone_repo "$reponame" "$reponame" |
| 1418 | |
| 1419 | gitscip-shell system . . git. lfs track "*.dat" |
| 1420 | |
| 1421 | setup_case_inverter_extension |
| 1422 | |
| 1423 | contents="abc" |
| 1424 | inverted_contents_oid="$(calc_oid "$(invert_case "$contents")")" |
| 1425 | mkdirscip-shell system . . mkdir. dir1 |
| 1426 | printfscip-shell system . . printf. "%s" "$contents" >dir1/abc.dat |
| 1427 | |
| 1428 | gitscip-shell system . . git. add .gitattributes dir1 |
| 1429 | gitscip-shell system . . git. commit -m "initial commit" |
| 1430 | |
| 1431 | gitscip-shell system . . git. push origin main |
| 1432 | assert_server_object "$reponame" "$inverted_contents_oid" |
| 1433 | |
| 1434 | cd .. |
| 1435 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. clone "$GITSERVER/$reponame" "${reponame}-assert" |
| 1436 | |
| 1437 | cd "${reponame}-assert" |
| 1438 | refute_local_object "$inverted_contents_oid" |
| 1439 | |
| 1440 | setup_case_inverter_extension |
| 1441 | |
| 1442 | rmscip-shell system . . rm. -rf dir1 "$LFSTEST_EXT_LOG" |
| 1443 | gitscip-shell system . . git. lfs pull |
| 1444 | |
| 1445 | assert_local_object "$inverted_contents_oid" 3 |
| 1446 | |
| 1447 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "dir1/abc.dat")" ] |
| 1448 | grepscip-shell system . . grep. "smudge: dir1/abc.dat" "$LFSTEST_EXT_LOG" |
| 1449 | |
| 1450 | rmscip-shell system . . rm. -rf .git/lfs/objects |
| 1451 | |
| 1452 | rmscip-shell system . . rm. -rf dir1 "$LFSTEST_EXT_LOG" |
| 1453 | mkdirscip-shell system . . mkdir. dir2 |
| 1454 | |
| 1455 | pushd dir2 |
| 1456 | gitscip-shell system . . git. lfs pull |
| 1457 | popd |
| 1458 | |
| 1459 | [scip-shell system . . `[`. "$contents" = "$(catscip-shell system . . cat. "dir1/abc.dat")" ] |
| 1460 | grepscip-shell system . . grep. "smudge: dir1/abc.dat" "$LFSTEST_EXT_LOG" |
| 1461 | |
| 1462 | assert_local_object "$inverted_contents_oid" 3 |
| 1463 | ) |
| 1464 | end_test |