2018-07-09 15:28:23 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-08-08 14:50:39 +00:00
|
|
|
. "$(dirname "$0")/testlib.sh"
|
2018-07-09 15:28:23 +00:00
|
|
|
|
|
|
|
begin_test "alternates (single)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="alternates-single-alternate"
|
|
|
|
setup_remote_repo_with_file "$reponame" "a.txt"
|
|
|
|
|
|
|
|
pushd "$TRASHDIR" > /dev/null
|
|
|
|
clone_repo "$reponame" "${reponame}_alternate"
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
rm -rf .git/lfs/objects
|
|
|
|
|
|
|
|
alternate="$TRASHDIR/${reponame}_alternate/.git/objects"
|
2019-08-14 13:49:43 +00:00
|
|
|
echo "$(native_path "$alternate")" > .git/objects/info/alternates
|
2018-07-09 15:28:23 +00:00
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
GIT_TRACE=1 git lfs fetch origin main 2>&1 | tee fetch.log
|
2018-07-09 15:28:23 +00:00
|
|
|
[ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "alternates (multiple)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="alternates-multiple-alternates"
|
|
|
|
setup_remote_repo_with_file "$reponame" "a.txt"
|
|
|
|
|
|
|
|
pushd "$TRASHDIR" > /dev/null
|
|
|
|
clone_repo "$reponame" "${reponame}_alternate_stale"
|
|
|
|
rm -rf .git/lfs/objects
|
|
|
|
popd > /dev/null
|
|
|
|
pushd "$TRASHDIR" > /dev/null
|
|
|
|
clone_repo "$reponame" "${reponame}_alternate"
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
rm -rf .git/lfs/objects
|
|
|
|
|
|
|
|
alternate_stale="$TRASHDIR/${reponame}_alternate_stale/.git/objects"
|
|
|
|
alternate="$TRASHDIR/${reponame}_alternate/.git/objects"
|
2019-08-14 13:49:43 +00:00
|
|
|
echo "$(native_path "$alternate")" > .git/objects/info/alternates
|
|
|
|
echo "$(native_path "$alternate_stale")" >> .git/objects/info/alternates
|
2018-07-09 15:28:23 +00:00
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
GIT_TRACE=1 git lfs fetch origin main 2>&1 | tee fetch.log
|
2018-07-09 15:28:23 +00:00
|
|
|
[ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "alternates (commented)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="alternates-commented-alternate"
|
|
|
|
setup_remote_repo_with_file "$reponame" "a.txt"
|
|
|
|
|
|
|
|
pushd "$TRASHDIR" > /dev/null
|
|
|
|
clone_repo "$reponame" "${reponame}_alternate"
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
rm -rf .git/lfs/objects
|
|
|
|
|
|
|
|
alternate="$TRASHDIR/${reponame}_alternate/.git/objects"
|
|
|
|
echo "# $alternate" > .git/objects/info/alternates
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
GIT_TRACE=1 git lfs fetch origin main 2>&1 | tee fetch.log
|
2018-07-09 15:28:23 +00:00
|
|
|
[ "1" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "alternates (quoted)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="alternates-quoted-alternate"
|
|
|
|
setup_remote_repo_with_file "$reponame" "a.txt"
|
|
|
|
|
|
|
|
pushd "$TRASHDIR" > /dev/null
|
|
|
|
clone_repo "$reponame" "${reponame}_alternate"
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
rm -rf .git/lfs/objects
|
|
|
|
|
2019-08-14 13:49:43 +00:00
|
|
|
# Normally, a plain native_path call would be sufficient here, but when we
|
|
|
|
# use a quoted alternate, Git interprets backslash escapes, and Windows path
|
|
|
|
# names look like backslash escapes. As a consequence, we switch to forward
|
|
|
|
# slashes to avoid misinterpretation.
|
|
|
|
alternate=$(native_path "$TRASHDIR/${reponame}_alternate/.git/objects" | sed -e 's,\\,/,g')
|
2018-07-09 15:28:23 +00:00
|
|
|
echo "\"$alternate\"" > .git/objects/info/alternates
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
GIT_TRACE=1 git lfs fetch origin main 2>&1 | tee fetch.log
|
2018-07-09 15:28:23 +00:00
|
|
|
[ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
|
|
|
|
)
|
|
|
|
end_test
|
2018-07-09 16:23:27 +00:00
|
|
|
|
|
|
|
begin_test "alternates (OS environment, single)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="alternates-environment-single-alternate"
|
|
|
|
setup_remote_repo_with_file "$reponame" "a.txt"
|
|
|
|
|
|
|
|
pushd "$TRASHDIR" > /dev/null
|
|
|
|
clone_repo "$reponame" "${reponame}_alternate"
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
rm -rf .git/lfs/objects
|
2019-07-25 19:29:13 +00:00
|
|
|
rm -rf .git/objects/*
|
|
|
|
git init
|
2018-07-09 16:23:27 +00:00
|
|
|
|
2019-08-14 13:49:43 +00:00
|
|
|
alternate="$(native_path "$TRASHDIR/${reponame}_alternate/.git/objects")"
|
2018-07-09 16:23:27 +00:00
|
|
|
|
|
|
|
GIT_ALTERNATE_OBJECT_DIRECTORIES="$alternate" \
|
|
|
|
GIT_TRACE=1 \
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs fetch origin main 2>&1 | tee fetch.log
|
2018-07-09 16:23:27 +00:00
|
|
|
[ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
|
2019-07-25 19:29:13 +00:00
|
|
|
GIT_ALTERNATE_OBJECT_DIRECTORIES="$alternate" \
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push "$(git config remote.origin.url)" main
|
2018-07-09 16:23:27 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "alternates (OS environment, multiple)"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="alternates-environment-multiple-alternates"
|
|
|
|
setup_remote_repo_with_file "$reponame" "a.txt"
|
|
|
|
|
|
|
|
pushd "$TRASHDIR" > /dev/null
|
|
|
|
clone_repo "$reponame" "${reponame}_alternate_stale"
|
|
|
|
rm -rf .git/lfs/objects
|
|
|
|
popd > /dev/null
|
|
|
|
pushd "$TRASHDIR" > /dev/null
|
|
|
|
clone_repo "$reponame" "${reponame}_alternate"
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
rm -rf .git/lfs/objects
|
2019-07-25 19:29:13 +00:00
|
|
|
rm -rf .git/objects/*
|
|
|
|
git init
|
2018-07-09 16:23:27 +00:00
|
|
|
|
2019-08-14 13:49:43 +00:00
|
|
|
alternate_stale="$(native_path "$TRASHDIR/${reponame}_alternate_stale/.git/objects")"
|
|
|
|
alternate="$(native_path "$TRASHDIR/${reponame}_alternate/.git/objects")"
|
2018-07-09 16:23:27 +00:00
|
|
|
sep="$(native_path_list_separator)"
|
|
|
|
|
|
|
|
GIT_ALTERNATE_OBJECT_DIRECTORIES="$alternate_stale$sep$alternate" \
|
|
|
|
GIT_TRACE=1 \
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs fetch origin main 2>&1 | tee fetch.log
|
2018-07-09 16:23:27 +00:00
|
|
|
[ "0" -eq "$(grep -c "sending batch of size 1" fetch.log)" ]
|
2019-07-25 19:29:13 +00:00
|
|
|
GIT_ALTERNATE_OBJECT_DIRECTORIES="$alternate_stale$sep$alternate" \
|
2020-06-29 16:18:57 +00:00
|
|
|
git lfs push "$(git config remote.origin.url)" main
|
2018-07-09 16:23:27 +00:00
|
|
|
)
|
|
|
|
end_test
|