2019-07-31 13:46:39 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
. "$(dirname "$0")/testlib.sh"
|
|
|
|
|
|
|
|
do_upload_download_test () {
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "Tracking"
|
|
|
|
|
|
|
|
git checkout -b test
|
|
|
|
|
|
|
|
# set up a decent amount of data so that there's work for multiple concurrent adapters
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1024},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":750}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1050},
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":660},
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":230}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":1200},
|
|
|
|
{\"Filename\":\"file6.dat\",\"Size\":300}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":120},
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":450},
|
|
|
|
{\"Filename\":\"file7.dat\",\"Size\":520},
|
|
|
|
{\"Filename\":\"file8.dat\",\"Size\":2048}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin test 2>&1 | tee pushcustom.log
|
|
|
|
# use PIPESTATUS otherwise we get exit code from tee
|
|
|
|
[ ${PIPESTATUS[0]} = "0" ]
|
|
|
|
|
|
|
|
ourobjects=$(cd .git && find lfs/objects -type f | sort)
|
|
|
|
theirobjects=$(cd $gitdir && find lfs/objects -type f | sort)
|
|
|
|
|
|
|
|
# Make sure the lock verification is not attempted.
|
|
|
|
grep "locks/verify$" pushcustom.log && false
|
|
|
|
|
|
|
|
grep "xfer: started custom adapter process" pushcustom.log
|
|
|
|
grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
|
|
|
|
[ "$ourobjects" = "$theirobjects" ]
|
|
|
|
|
|
|
|
rm -rf .git/lfs/objects
|
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
|
|
|
|
[ ${PIPESTATUS[0]} = "0" ]
|
|
|
|
|
|
|
|
objectlist=$(find .git/lfs/objects -type f)
|
|
|
|
[ "$(echo "$objectlist" | wc -l)" -eq 12 ]
|
|
|
|
}
|
|
|
|
|
2023-06-21 13:07:29 +00:00
|
|
|
do_local_path_test () {
|
|
|
|
local reponame="$1"
|
lfsapi: gracefully handle local paths with trailing slash
When we want to handle a local path, we must rewrite it internally into
a `file:///` URL, because we dispatch our standalone transfer agent
based on the URL scheme. However, once we've looked up an appropriate
URL and formatted it as the scheme prefers, if it contains a trailing
slash, we ignore the entire lookup and replace the URL with the raw one
given, but without the trailing slash.
This behaviour seems a bit bizarre, and it causes us to take a local
path with a trailing slash and treat it not as the `file:///` URL it
needs to be, but as a raw local path, which gets refused. Let's avoid
this problem by looking at the rewritten URL, and modifying that instead
if we find its trailing slash to be offensive.
2023-06-21 13:09:29 +00:00
|
|
|
local suffix="$2"
|
2023-06-21 13:07:29 +00:00
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "Tracking"
|
|
|
|
|
|
|
|
git checkout -b test
|
|
|
|
|
|
|
|
# set up a decent amount of data so that there's work for multiple concurrent adapters
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1024},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":750}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1050},
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":660},
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":230}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":1200},
|
|
|
|
{\"Filename\":\"file6.dat\",\"Size\":300}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":120},
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":450},
|
|
|
|
{\"Filename\":\"file7.dat\",\"Size\":520},
|
|
|
|
{\"Filename\":\"file8.dat\",\"Size\":2048}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
testdir="$(pwd)"
|
|
|
|
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
|
|
|
|
# Check a clone using an absolute Unix-style path.
|
lfsapi: gracefully handle local paths with trailing slash
When we want to handle a local path, we must rewrite it internally into
a `file:///` URL, because we dispatch our standalone transfer agent
based on the URL scheme. However, once we've looked up an appropriate
URL and formatted it as the scheme prefers, if it contains a trailing
slash, we ignore the entire lookup and replace the URL with the raw one
given, but without the trailing slash.
This behaviour seems a bit bizarre, and it causes us to take a local
path with a trailing slash and treat it not as the `file:///` URL it
needs to be, but as a raw local path, which gets refused. Let's avoid
this problem by looking at the rewritten URL, and modifying that instead
if we find its trailing slash to be offensive.
2023-06-21 13:09:29 +00:00
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git clone "$testdir$suffix" "$reponame-repo1" 2>&1 | tee clonecustom.log
|
2023-06-21 13:07:29 +00:00
|
|
|
(cd "$reponame-repo1" && git lfs fsck)
|
|
|
|
grep "xfer: started custom adapter process" clonecustom.log
|
|
|
|
|
|
|
|
# Check a clone using a relative path.
|
lfsapi: gracefully handle local paths with trailing slash
When we want to handle a local path, we must rewrite it internally into
a `file:///` URL, because we dispatch our standalone transfer agent
based on the URL scheme. However, once we've looked up an appropriate
URL and formatted it as the scheme prefers, if it contains a trailing
slash, we ignore the entire lookup and replace the URL with the raw one
given, but without the trailing slash.
This behaviour seems a bit bizarre, and it causes us to take a local
path with a trailing slash and treat it not as the `file:///` URL it
needs to be, but as a raw local path, which gets refused. Let's avoid
this problem by looking at the rewritten URL, and modifying that instead
if we find its trailing slash to be offensive.
2023-06-21 13:09:29 +00:00
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git clone "$reponame-repo1$suffix" "$reponame-repo2" 2>&1 | tee clonecustom.log
|
2023-06-21 13:07:29 +00:00
|
|
|
(cd "$reponame-repo2" && git lfs fsck)
|
|
|
|
grep "xfer: started custom adapter process" clonecustom.log
|
|
|
|
|
|
|
|
# Check a clone using an absolute native-style path.
|
lfsapi: gracefully handle local paths with trailing slash
When we want to handle a local path, we must rewrite it internally into
a `file:///` URL, because we dispatch our standalone transfer agent
based on the URL scheme. However, once we've looked up an appropriate
URL and formatted it as the scheme prefers, if it contains a trailing
slash, we ignore the entire lookup and replace the URL with the raw one
given, but without the trailing slash.
This behaviour seems a bit bizarre, and it causes us to take a local
path with a trailing slash and treat it not as the `file:///` URL it
needs to be, but as a raw local path, which gets refused. Let's avoid
this problem by looking at the rewritten URL, and modifying that instead
if we find its trailing slash to be offensive.
2023-06-21 13:09:29 +00:00
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git clone "$(native_path "$testdir")$suffix" "$reponame-repo3" 2>&1 | tee clonecustom.log
|
2023-06-21 13:07:29 +00:00
|
|
|
(cd "$reponame-repo3" && git lfs fsck)
|
|
|
|
grep "xfer: started custom adapter process" clonecustom.log
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-07-31 13:46:39 +00:00
|
|
|
begin_test "standalone-file-upload-download-bare"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# setup a git repo to be used as a local repo, not remote
|
|
|
|
reponame="standalone-file-upload-download-bare"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
git init --bare "$reponame-2.git"
|
|
|
|
gitdir="$(pwd)/$reponame-2.git"
|
|
|
|
|
|
|
|
# clone directly, not through lfstest-gitserver
|
|
|
|
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
|
|
|
|
|
|
|
|
git remote set-url origin "file://$(urlify "$gitdir")"
|
|
|
|
|
|
|
|
do_upload_download_test
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "standalone-file-upload-download-non-bare"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# setup a git repo to be used as a local repo, not remote
|
|
|
|
reponame="standalone-file-upload-download-non-bare"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
git init "$reponame-2.git"
|
|
|
|
repo2="$(pwd)/$reponame-2.git"
|
|
|
|
gitdir="$(pwd)/$reponame-2.git/.git"
|
|
|
|
|
|
|
|
# clone directly, not through lfstest-gitserver
|
|
|
|
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
|
|
|
|
|
|
|
|
git remote set-url origin "file://$(urlify "$repo2")"
|
|
|
|
|
|
|
|
do_upload_download_test
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "standalone-file-download-missing-file"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# setup a git repo to be used as a local repo, not remote
|
|
|
|
reponame="standalone-file-download-missing-file"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
otherrepo="$(pwd)/$reponame-2.git"
|
|
|
|
git init --bare "$otherrepo"
|
|
|
|
|
|
|
|
# clone directly, not through lfstest-gitserver
|
|
|
|
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
|
|
|
|
|
|
|
|
git remote set-url origin "file://$(urlify "$otherrepo")"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "Tracking"
|
|
|
|
|
|
|
|
git checkout -b test
|
|
|
|
|
|
|
|
# set up a decent amount of data so that there's work for multiple concurrent adapters
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1024},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":750}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1050},
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":660},
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":230}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":1200},
|
|
|
|
{\"Filename\":\"file6.dat\",\"Size\":300}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":120},
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":450},
|
|
|
|
{\"Filename\":\"file7.dat\",\"Size\":520},
|
|
|
|
{\"Filename\":\"file8.dat\",\"Size\":2048}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin test 2>&1 | tee pushcustom.log
|
|
|
|
# use PIPESTATUS otherwise we get exit code from tee
|
|
|
|
[ ${PIPESTATUS[0]} = "0" ]
|
|
|
|
|
|
|
|
# Make sure the lock verification is not attempted.
|
|
|
|
grep "locks/verify$" pushcustom.log && false
|
|
|
|
|
|
|
|
grep "xfer: started custom adapter process" pushcustom.log
|
|
|
|
grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
|
|
|
|
|
|
|
|
# Delete an object from the remote side. Any object will do.
|
|
|
|
rm -f $(find "$otherrepo/lfs/objects" -type f | head -n1)
|
|
|
|
|
|
|
|
rm -rf .git/lfs/objects
|
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
|
|
|
|
# Make sure we failed.
|
|
|
|
[ ${PIPESTATUS[0]} != "0" ]
|
|
|
|
|
|
|
|
# Make sure we downloaded the rest of the objects.
|
|
|
|
objectlist=$(find .git/lfs/objects -type f)
|
|
|
|
[ "$(echo "$objectlist" | wc -l)" -eq 11 ]
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "standalone-file-clone"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# setup a git repo to be used as a local repo, not remote
|
|
|
|
reponame="standalone-file-clone"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
# clone directly, not through lfstest-gitserver
|
|
|
|
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "Tracking"
|
|
|
|
|
|
|
|
git checkout -b test
|
|
|
|
|
|
|
|
# set up a decent amount of data so that there's work for multiple concurrent adapters
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1024},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":750}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1050},
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":660},
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":230}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":1200},
|
|
|
|
{\"Filename\":\"file6.dat\",\"Size\":300}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":120},
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":450},
|
|
|
|
{\"Filename\":\"file7.dat\",\"Size\":520},
|
|
|
|
{\"Filename\":\"file8.dat\",\"Size\":2048}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
testdir="$(pwd)"
|
|
|
|
|
|
|
|
cd "$TRASHDIR"
|
|
|
|
|
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git clone "file://$(urlify "$testdir")" repo3 2>&1 | tee clonecustom.log
|
|
|
|
|
|
|
|
grep "xfer: started custom adapter process" clonecustom.log
|
|
|
|
)
|
|
|
|
end_test
|
2019-11-06 22:23:22 +00:00
|
|
|
|
Add support for local paths
Currently, we only support local remotes using file URLs, but not local
paths. This is a highly requested feature, however, so implement
support for local paths as remotes.
First, fix the handling of local paths we already have: the handling of
absolute Unix-style paths. Instead of checking for the remote to
contain a file URL to determine whether to append "info/lfs" to the URL,
look to see if the URL we're using is a file URL, which will catch local
paths which will have been rewritten as such by this point. The
"info/lfs" part of the URL is not handled by the transfer adapter, so we
don't want to add it on.
If we get something that looks like it's not a URL, check if it's a
file on the file system, and if so, don't attempt to interpret it as an
SSH URL. This fixes the confusion with Windows paths, which resemble
SSH-style locations with a single-letter alias as the host name.
Finally, when turning a local path into a file URL, turn the path into
an absolute one if possible and rewrite it using slashes, which is
required for file URLs. Add several tests for the various cases: one
for Unix-style paths, one for native paths, and one for relative paths.
2019-11-13 21:16:45 +00:00
|
|
|
begin_test "standalone-file-local-path"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# setup a git repo to be used as a local repo, not remote
|
|
|
|
reponame="standalone-file-local-path"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
# clone directly, not through lfstest-gitserver
|
|
|
|
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
|
|
|
|
|
lfsapi: gracefully handle local paths with trailing slash
When we want to handle a local path, we must rewrite it internally into
a `file:///` URL, because we dispatch our standalone transfer agent
based on the URL scheme. However, once we've looked up an appropriate
URL and formatted it as the scheme prefers, if it contains a trailing
slash, we ignore the entire lookup and replace the URL with the raw one
given, but without the trailing slash.
This behaviour seems a bit bizarre, and it causes us to take a local
path with a trailing slash and treat it not as the `file:///` URL it
needs to be, but as a raw local path, which gets refused. Let's avoid
this problem by looking at the rewritten URL, and modifying that instead
if we find its trailing slash to be offensive.
2023-06-21 13:09:29 +00:00
|
|
|
do_local_path_test "$reponame" ""
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "standalone-file-local-path-trailing-slash"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# setup a git repo to be used as a local repo, not remote
|
|
|
|
reponame="standalone-file-local-path-trailing-slash"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
# clone directly, not through lfstest-gitserver
|
|
|
|
clone_repo_url "$REMOTEDIR/$reponame.git/" $reponame
|
|
|
|
|
|
|
|
do_local_path_test "$reponame" "$suffix"
|
Add support for local paths
Currently, we only support local remotes using file URLs, but not local
paths. This is a highly requested feature, however, so implement
support for local paths as remotes.
First, fix the handling of local paths we already have: the handling of
absolute Unix-style paths. Instead of checking for the remote to
contain a file URL to determine whether to append "info/lfs" to the URL,
look to see if the URL we're using is a file URL, which will catch local
paths which will have been rewritten as such by this point. The
"info/lfs" part of the URL is not handled by the transfer adapter, so we
don't want to add it on.
If we get something that looks like it's not a URL, check if it's a
file on the file system, and if so, don't attempt to interpret it as an
SSH URL. This fixes the confusion with Windows paths, which resemble
SSH-style locations with a single-letter alias as the host name.
Finally, when turning a local path into a file URL, turn the path into
an absolute one if possible and rewrite it using slashes, which is
required for file URLs. Add several tests for the various cases: one
for Unix-style paths, one for native paths, and one for relative paths.
2019-11-13 21:16:45 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2019-11-06 22:23:22 +00:00
|
|
|
begin_test "standalone-file-lfs.url file URL"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# setup a git repo to be used as a local repo, not remote
|
|
|
|
reponame="standalone-file-lfsurl"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
# clone directly, not through lfstest-gitserver
|
|
|
|
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
|
|
|
|
|
|
|
|
otherrepo="$(pwd)/$reponame-2.git"
|
|
|
|
git init --bare "$otherrepo"
|
|
|
|
|
|
|
|
wrongrepo="$(pwd)/$reponame-3.git"
|
|
|
|
git init --bare "$wrongrepo"
|
|
|
|
|
|
|
|
git remote set-url origin "file://$(urlify "$wrongrepo")"
|
|
|
|
git config lfs.url "file://$(urlify "$otherrepo")"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "Tracking"
|
|
|
|
|
|
|
|
git checkout -b test
|
|
|
|
|
|
|
|
# set up a decent amount of data so that there's work for multiple concurrent adapters
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1024},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":750}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1050},
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":660},
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":230}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":1200},
|
|
|
|
{\"Filename\":\"file6.dat\",\"Size\":300}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":120},
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":450},
|
|
|
|
{\"Filename\":\"file7.dat\",\"Size\":520},
|
|
|
|
{\"Filename\":\"file8.dat\",\"Size\":2048}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin test 2>&1 | tee pushcustom.log
|
|
|
|
# use PIPESTATUS otherwise we get exit code from tee
|
|
|
|
[ ${PIPESTATUS[0]} = "0" ]
|
|
|
|
|
|
|
|
# Make sure the lock verification is not attempted.
|
|
|
|
grep "locks/verify$" pushcustom.log && false
|
|
|
|
|
|
|
|
grep "xfer: started custom adapter process" pushcustom.log
|
|
|
|
grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
|
|
|
|
|
|
|
|
# Make sure we didn't write to the wrong repo.
|
|
|
|
objectlist=$(find "$wrongrepo/lfs/objects" -type f || true)
|
|
|
|
[ -z "$objectlist" ]
|
|
|
|
|
|
|
|
# Make sure we uploaded the expected number of objects.
|
|
|
|
objectlist=$(find "$otherrepo/lfs/objects" -type f || true)
|
|
|
|
[ "$(echo "$objectlist" | wc -l)" -eq 12 ]
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "standalone-file-lfs.url http URL"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="standalone-file-lfsurl-http"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
# clone directly, not through lfstest-gitserver
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
wrongrepo="$(pwd)/$reponame-2.git"
|
|
|
|
git init --bare "$wrongrepo"
|
|
|
|
|
|
|
|
git remote set-url origin "file://$(urlify "$wrongrepo")"
|
|
|
|
git config lfs.url "$(repo_endpoint "$GITSERVER" "$reponame")"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "Tracking"
|
|
|
|
|
|
|
|
git checkout -b test
|
|
|
|
|
|
|
|
# set up a decent amount of data so that there's work for multiple concurrent adapters
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1024},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":750}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1050},
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":660},
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":230}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":1200},
|
|
|
|
{\"Filename\":\"file6.dat\",\"Size\":300}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":120},
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":450},
|
|
|
|
{\"Filename\":\"file7.dat\",\"Size\":520},
|
|
|
|
{\"Filename\":\"file8.dat\",\"Size\":2048}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin test 2>&1 | tee push.log
|
|
|
|
# use PIPESTATUS otherwise we get exit code from tee
|
|
|
|
[ ${PIPESTATUS[0]} = "0" ]
|
|
|
|
|
|
|
|
# We should not use the custom adapter process here.
|
t: avoid incorrect negated commands
When `set -e` is enabled, not all commands trigger an error exit if they
return false. For example, it's clear that commands in an `if` or
`while` statement don't cause an error if they are false.
What is less obvious, however, is that negated commands and negated
pipelines also have no effect on `set -e`. From POSIX 1003.1-2017 (on
`sh -e`):
When this option is on, if a simple command fails for any of the
reasons listed in Consequences of Shell Errors or returns an exit
status value >0, and is not part of the compound list following a
while, until, or if keyword, and is not a part of an AND or OR list,
and is not a pipeline preceded by the ! reserved word, then the
shell shall immediately exit.
As such, writing something like `! grep` will never fail. Fortunately,
we can append `&& exit 1` instead of the `!` and that will work
correctly.
To make this work, run the following command to make the code properly
check the exit status of our commands:
git grep -l '! [a-z]' t | \
xargs ruby -pi -e '$_.gsub!(/^(\s+)! ([a-z].*)$/, "\\1\\2 && exit 1")'
Because such a command will still have a non-zero exit status, even if
it doesn't trigger `set -e`, add a `true` if this is the last statement
in a block, so that the test exits successfully and therefore passes.
2023-02-13 19:49:59 +00:00
|
|
|
grep "xfer: started custom adapter process" push.log && exit 1
|
2019-11-06 22:23:22 +00:00
|
|
|
grep -F "$GITSERVER/$reponame" push.log
|
|
|
|
|
|
|
|
# Make sure we didn't write to the wrong repo.
|
|
|
|
objectlist=$(find "$wrongrepo/lfs/objects" -type f || true)
|
|
|
|
[ -z "$objectlist" ]
|
|
|
|
|
|
|
|
rm -fr .git/lfs/objects
|
|
|
|
|
|
|
|
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetch.log
|
t: avoid incorrect negated commands
When `set -e` is enabled, not all commands trigger an error exit if they
return false. For example, it's clear that commands in an `if` or
`while` statement don't cause an error if they are false.
What is less obvious, however, is that negated commands and negated
pipelines also have no effect on `set -e`. From POSIX 1003.1-2017 (on
`sh -e`):
When this option is on, if a simple command fails for any of the
reasons listed in Consequences of Shell Errors or returns an exit
status value >0, and is not part of the compound list following a
while, until, or if keyword, and is not a part of an AND or OR list,
and is not a pipeline preceded by the ! reserved word, then the
shell shall immediately exit.
As such, writing something like `! grep` will never fail. Fortunately,
we can append `&& exit 1` instead of the `!` and that will work
correctly.
To make this work, run the following command to make the code properly
check the exit status of our commands:
git grep -l '! [a-z]' t | \
xargs ruby -pi -e '$_.gsub!(/^(\s+)! ([a-z].*)$/, "\\1\\2 && exit 1")'
Because such a command will still have a non-zero exit status, even if
it doesn't trigger `set -e`, add a `true` if this is the last statement
in a block, so that the test exits successfully and therefore passes.
2023-02-13 19:49:59 +00:00
|
|
|
grep "xfer: started custom adapter process" fetch.log && exit 1
|
2019-11-06 22:23:22 +00:00
|
|
|
grep -F "$GITSERVER/$reponame" fetch.log
|
|
|
|
|
|
|
|
git lfs fsck
|
|
|
|
)
|
|
|
|
end_test
|
2023-02-13 20:42:40 +00:00
|
|
|
|
|
|
|
begin_test "standalone-file error"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="standalone-file-error"
|
|
|
|
setup_remote_repo "$reponame"
|
|
|
|
|
|
|
|
# clone directly, not through lfstest-gitserver
|
|
|
|
clone_repo "$reponame" "$reponame"
|
|
|
|
|
|
|
|
otherrepo="$(pwd)/$reponame-2.git"
|
|
|
|
mkdir "$otherrepo"
|
|
|
|
|
|
|
|
git remote set-url origin "file://$(urlify "$otherrepo")"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m "Tracking"
|
|
|
|
|
|
|
|
git checkout -b test
|
|
|
|
|
|
|
|
# set up a decent amount of data so that there's work for multiple concurrent adapters
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1024},
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":750}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file1.dat\",\"Size\":1050},
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":660},
|
|
|
|
{\"Filename\":\"file4.dat\",\"Size\":230}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":1200},
|
|
|
|
{\"Filename\":\"file6.dat\",\"Size\":300}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file3.dat\",\"Size\":120},
|
|
|
|
{\"Filename\":\"file5.dat\",\"Size\":450},
|
|
|
|
{\"Filename\":\"file7.dat\",\"Size\":520},
|
|
|
|
{\"Filename\":\"file8.dat\",\"Size\":2048}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
if git push origin test 2>pusherror.log
|
|
|
|
then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cat pusherror.log
|
|
|
|
grep 'not.*a git repository' pusherror.log
|
|
|
|
)
|
|
|
|
end_test
|