| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh" |
| 4 | |
| 5 | assert_same_inodescip-shell shell shell-project 0.0.0 assert_same_inode().() { |
| 6 | local repo1=$1 |
| 7 | local repo2=$2 |
| 8 | local oid=$3 |
| 9 | |
| 10 | if ! unamescip-shell system . . uname. -s | grepscip-shell system . . grep. -qE 'CYGWIN|MSYS|MINGW'; then |
| 11 | cfg1=$(cd "$repo1"; gitscip-shell system . . git. lfs env | grepscip-shell system . . grep. LocalMediaDir) |
| 12 | f1="${cfg1:14}/${oid:0:2}/${oid:2:2}/$oid" |
| 13 | inode1=$(lsscip-shell system . . ls. -i $f1 | cutscip-shell system . . cut. -f1 -d\ ) |
| 14 | |
| 15 | cfg2=$(cd "$repo2"; gitscip-shell system . . git. lfs env | grepscip-shell system . . grep. LocalMediaDir) |
| 16 | f2="${cfg2:14}/${oid:0:2}/${oid:2:2}/$oid" |
| 17 | inode2=$(lsscip-shell system . . ls. -i $f2 | cutscip-shell system . . cut. -f1 -d\ ) |
| 18 | |
| 19 | [scip-shell system . . `[`. "$inode1" == "$inode2" ] |
| 20 | fi |
| 21 | } |
| 22 | |
| 23 | begin_test "clone with reference" |
| 24 | ( |
| 25 | set -e |
| 26 | |
| 27 | reponame="$(basenamescip-shell system . . basename. "$0" ".sh")" |
| 28 | setup_remote_repo "$reponame" |
| 29 | |
| 30 | ref_repo=clone_reference_repo |
| 31 | ref_repo_dir=$TRASHDIR/$ref_repo |
| 32 | clone_repo "$reponame" "$ref_repo" |
| 33 | gitscip-shell system . . git. lfs track "*.dat" |
| 34 | contents="a" |
| 35 | oid=$(calc_oid "$contents") |
| 36 | |
| 37 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 38 | gitscip-shell system . . git. add a.dat |
| 39 | gitscip-shell system . . git. add .gitattributes |
| 40 | gitscip-shell system . . git. commit -m "add a.dat" 2>&1 |
| 41 | gitscip-shell system . . git. push origin main |
| 42 | |
| 43 | delete_server_object "$reponame" "$oid" |
| 44 | |
| 45 | repo=test_repo |
| 46 | repo_dir=$TRASHDIR/$repo |
| 47 | gitscip-shell system . . git. clone --reference "$ref_repo_dir/.git" \ |
| 48 | "$GITSERVER/$reponame" "$repo_dir" |
| 49 | |
| 50 | cd "$TRASHDIR/$repo" |
| 51 | |
| 52 | assert_pointer "main" "a.dat" "$oid" 1 |
| 53 | assert_same_inodescip-shell shell shell-project 0.0.0 assert_same_inode(). "$repo_dir" "$ref_repo_dir" "$oid" |
| 54 | ) |
| 55 | end_test |
| 56 | |
| 57 | begin_test "fetch from clone reference" |
| 58 | ( |
| 59 | set -e |
| 60 | |
| 61 | reponame="$(basenamescip-shell system . . basename. "$0" ".sh")2" |
| 62 | setup_remote_repo "$reponame" |
| 63 | |
| 64 | ref_repo=clone_reference_repo2 |
| 65 | ref_repo_dir=$TRASHDIR/$ref_repo |
| 66 | clone_repo "$reponame" "$ref_repo" |
| 67 | |
| 68 | repo=test_repo2 |
| 69 | repo_dir=$TRASHDIR/$repo |
| 70 | gitscip-shell system . . git. clone --reference "$ref_repo_dir/.git" \ |
| 71 | "$GITSERVER/$reponame" "$repo_dir" 2> clone.log |
| 72 | |
| 73 | cd "$ref_repo_dir" |
| 74 | gitscip-shell system . . git. lfs track "*.dat" |
| 75 | contents="a" |
| 76 | oid=$(calc_oid "$contents") |
| 77 | |
| 78 | printfscip-shell system . . printf. "%s" "$contents" > a.dat |
| 79 | gitscip-shell system . . git. add a.dat |
| 80 | gitscip-shell system . . git. add .gitattributes |
| 81 | gitscip-shell system . . git. commit -m "add a.dat" 2>&1 |
| 82 | gitscip-shell system . . git. push origin main |
| 83 | |
| 84 | delete_server_object "$reponame" "$oid" |
| 85 | |
| 86 | cd "$repo_dir" |
| 87 | GIT_LFS_SKIP_SMUDGE=1 gitscip-shell system . . git. pull origin main |
| 88 | gitscip-shell system . . git. lfs pull |
| 89 | |
| 90 | assert_pointer "main" "a.dat" "$oid" 1 |
| 91 | assert_same_inodescip-shell shell shell-project 0.0.0 assert_same_inode(). "$TRASHDIR/$repo" "$TRASHDIR/$ref_repo" "$oid" |
| 92 | ) |
| 93 | end_test |