1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#!/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"'
if [ "$IS_WINDOWS" -eq 1 ]; then
export MSYS2_ENV_CONV_EXCL="GIT_LFS_TEST_DIR"
fi
# The "git lfs env" command should ignore this environment variable
# despite the "GIT_" strings in its name and value.
export TEST_GIT_EXAMPLE="GIT_EXAMPLE"
begin_test "git worktree"
(
set -e
reponame="worktree-main"
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
PruneVerifyUnreachableAlways=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
PruneVerifyUnreachableAlways=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"
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
|