9e006ac4e2
Currently, our default branch in tests is "master". This is the Git default, but the Git default will likely change in the future, so it makes sense to update our testsuite to be explicit about the branch name. We'll ensure this continues by building against older versions of Git as well as newer versions. We use "main" for the new branch name, since that's the proposed value upstream. This commit was made entirely by automated means using the following command: git grep -l master t | xargs sed -i -e 's/master/main/g'
94 lines
2.0 KiB
Bash
Executable File
94 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
. "$(dirname "$0")/testlib.sh"
|
|
|
|
assert_same_inode() {
|
|
local repo1=$1
|
|
local repo2=$2
|
|
local oid=$3
|
|
|
|
if ! uname -s | grep -qE 'CYGWIN|MSYS|MINGW'; then
|
|
cfg1=$(cd "$repo1"; git lfs env | grep LocalMediaDir)
|
|
f1="${cfg1:14}/${oid:0:2}/${oid:2:2}/$oid"
|
|
inode1=$(ls -i $f1 | cut -f1 -d\ )
|
|
|
|
cfg2=$(cd "$repo2"; git lfs env | grep LocalMediaDir)
|
|
f2="${cfg2:14}/${oid:0:2}/${oid:2:2}/$oid"
|
|
inode2=$(ls -i $f2 | cut -f1 -d\ )
|
|
|
|
[ "$inode1" == "$inode2" ]
|
|
fi
|
|
}
|
|
|
|
begin_test "clone with reference"
|
|
(
|
|
set -e
|
|
|
|
reponame="$(basename "$0" ".sh")"
|
|
setup_remote_repo "$reponame"
|
|
|
|
ref_repo=clone_reference_repo
|
|
ref_repo_dir=$TRASHDIR/$ref_repo
|
|
clone_repo "$reponame" "$ref_repo"
|
|
git lfs track "*.dat"
|
|
contents="a"
|
|
oid=$(calc_oid "$contents")
|
|
|
|
printf "%s" "$contents" > a.dat
|
|
git add a.dat
|
|
git add .gitattributes
|
|
git commit -m "add a.dat" 2>&1
|
|
git push origin main
|
|
|
|
delete_server_object "$reponame" "$oid"
|
|
|
|
repo=test_repo
|
|
repo_dir=$TRASHDIR/$repo
|
|
git clone --reference "$ref_repo_dir/.git" \
|
|
"$GITSERVER/$reponame" "$repo_dir"
|
|
|
|
cd "$TRASHDIR/$repo"
|
|
|
|
assert_pointer "main" "a.dat" "$oid" 1
|
|
assert_same_inode "$repo_dir" "$ref_repo_dir" "$oid"
|
|
)
|
|
end_test
|
|
|
|
begin_test "fetch from clone reference"
|
|
(
|
|
set -e
|
|
|
|
reponame="$(basename "$0" ".sh")2"
|
|
setup_remote_repo "$reponame"
|
|
|
|
ref_repo=clone_reference_repo2
|
|
ref_repo_dir=$TRASHDIR/$ref_repo
|
|
clone_repo "$reponame" "$ref_repo"
|
|
|
|
repo=test_repo2
|
|
repo_dir=$TRASHDIR/$repo
|
|
git clone --reference "$ref_repo_dir/.git" \
|
|
"$GITSERVER/$reponame" "$repo_dir" 2> clone.log
|
|
|
|
cd "$ref_repo_dir"
|
|
git lfs track "*.dat"
|
|
contents="a"
|
|
oid=$(calc_oid "$contents")
|
|
|
|
printf "%s" "$contents" > a.dat
|
|
git add a.dat
|
|
git add .gitattributes
|
|
git commit -m "add a.dat" 2>&1
|
|
git push origin main
|
|
|
|
delete_server_object "$reponame" "$oid"
|
|
|
|
cd "$repo_dir"
|
|
GIT_LFS_SKIP_SMUDGE=1 git pull origin main
|
|
git lfs pull
|
|
|
|
assert_pointer "main" "a.dat" "$oid" 1
|
|
assert_same_inode "$TRASHDIR/$repo" "$TRASHDIR/$ref_repo" "$oid"
|
|
)
|
|
end_test
|