594f8e386c
A pure SSH-based protocol has been a long time request from many users, so let's implement one. Implement basic upload and download support, plus batch requests, and support pkt-line tracing for text packets to make debugging easier. Note that locking is not yet supported; that will come in a future patch. We prefer the Endpoint function to the RemoteEndpoint function because the former handles lfs.url and the latter does not. Update a comment about the shared temporary directory; it is no longer cleared automatically by the adapter, and instead the cleanup happens later in other code. Therefore, it is safe to share the directory among the transport adapters. Co-authored-by: Chris Darroch <chrisd8088@github.com>
125 lines
3.9 KiB
Bash
Executable File
125 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
. "$(dirname "$0")/testlib.sh"
|
|
|
|
ensure_git_version_isnt $VERSION_LOWER "2.5.0"
|
|
envInitConfig='git config filter.lfs.process = "git-lfs filter-process"
|
|
git config filter.lfs.smudge = "git-lfs smudge -- %f"
|
|
git config filter.lfs.clean = "git-lfs clean -- %f"'
|
|
|
|
unset_vars () {
|
|
# If set, these will cause the test to fail.
|
|
unset GIT_LFS_NO_TEST_COUNT GIT_LFS_LOCK_ACQUIRE_DISABLED
|
|
}
|
|
|
|
begin_test "git worktree"
|
|
(
|
|
set -e
|
|
reponame="worktree-main"
|
|
unset_vars
|
|
mkdir $reponame
|
|
cd $reponame
|
|
git init
|
|
|
|
# can't create a worktree until there's 1 commit at least
|
|
echo "a" > tmp.txt
|
|
git add tmp.txt
|
|
git commit -m "Initial commit"
|
|
|
|
expected=$(printf "%s\n%s\n
|
|
LocalWorkingDir=$(canonical_path_escaped "$TRASHDIR/$reponame")
|
|
LocalGitDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git")
|
|
LocalGitStorageDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git")
|
|
LocalMediaDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs/objects")
|
|
LocalReferenceDirs=
|
|
TempDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs/tmp")
|
|
ConcurrentTransfers=8
|
|
TusTransfers=false
|
|
BasicTransfersOnly=false
|
|
SkipDownloadErrors=false
|
|
FetchRecentAlways=false
|
|
FetchRecentRefsDays=7
|
|
FetchRecentCommitsDays=0
|
|
FetchRecentRefsIncludeRemotes=true
|
|
PruneOffsetDays=3
|
|
PruneVerifyRemoteAlways=false
|
|
PruneRemoteName=origin
|
|
LfsStorageDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs")
|
|
AccessDownload=none
|
|
AccessUpload=none
|
|
DownloadTransfers=basic,lfs-standalone-file,ssh
|
|
UploadTransfers=basic,lfs-standalone-file,ssh
|
|
$(escape_path "$(env | grep "^GIT")")
|
|
%s
|
|
" "$(git lfs version)" "$(git version)" "$envInitConfig")
|
|
actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=")
|
|
contains_same_elements "$expected" "$actual"
|
|
|
|
worktreename="worktree-2"
|
|
git worktree add "$TRASHDIR/$worktreename"
|
|
cd "$TRASHDIR/$worktreename"
|
|
|
|
# git dir in worktree is like submodules (except path is worktrees) but this
|
|
# is only for index, temp etc
|
|
# storage of git objects and lfs objects is in the original .git
|
|
expected=$(printf "%s\n%s\n
|
|
LocalWorkingDir=$(canonical_path_escaped "$TRASHDIR/$worktreename")
|
|
LocalGitDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/worktrees/$worktreename")
|
|
LocalGitStorageDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git")
|
|
LocalMediaDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs/objects")
|
|
LocalReferenceDirs=
|
|
TempDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs/tmp")
|
|
ConcurrentTransfers=8
|
|
TusTransfers=false
|
|
BasicTransfersOnly=false
|
|
SkipDownloadErrors=false
|
|
FetchRecentAlways=false
|
|
FetchRecentRefsDays=7
|
|
FetchRecentCommitsDays=0
|
|
FetchRecentRefsIncludeRemotes=true
|
|
PruneOffsetDays=3
|
|
PruneVerifyRemoteAlways=false
|
|
PruneRemoteName=origin
|
|
LfsStorageDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs")
|
|
AccessDownload=none
|
|
AccessUpload=none
|
|
DownloadTransfers=basic,lfs-standalone-file,ssh
|
|
UploadTransfers=basic,lfs-standalone-file,ssh
|
|
$(escape_path "$(env | grep "^GIT")")
|
|
%s
|
|
" "$(git lfs version)" "$(git version)" "$envInitConfig")
|
|
actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=")
|
|
contains_same_elements "$expected" "$actual"
|
|
)
|
|
end_test
|
|
|
|
begin_test "git worktree with hooks"
|
|
(
|
|
set -e
|
|
reponame="worktree-hooks"
|
|
unset_vars
|
|
mkdir $reponame
|
|
cd $reponame
|
|
git init
|
|
|
|
# can't create a worktree until there's 1 commit at least
|
|
echo "a" > tmp.txt
|
|
git add tmp.txt
|
|
git commit -m "Initial commit"
|
|
|
|
worktreename="worktree-2-hook"
|
|
git worktree add "$TRASHDIR/$worktreename"
|
|
cd "$TRASHDIR/$worktreename"
|
|
|
|
# No hooks so far.
|
|
[ ! -e "$TRASHDIR/$reponame/.git/worktrees/$worktreename/hooks" ]
|
|
[ ! -e "$TRASHDIR/$reponame/.git/hooks/pre-push" ]
|
|
|
|
git lfs install
|
|
|
|
# Make sure we installed the hooks in the main repo, not the worktree dir.
|
|
[ ! -e "$TRASHDIR/$reponame/.git/worktrees/$worktreename/hooks" ]
|
|
[ -x "$TRASHDIR/$reponame/.git/hooks/pre-push" ]
|
|
)
|
|
end_test
|