Debian Codegraph @

t/t-worktree.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh"
4
5 ensure_git_version_isnt $VERSION_LOWER "2.5.0"
6 envInitConfig='git config filter.lfs.process = "git-lfs filter-process"
7 git config filter.lfs.smudge = "git-lfs smudge -- %f"
8 git config filter.lfs.clean = "git-lfs clean -- %f"'
9
10 if [scip-shell system . . `[`. "$IS_WINDOWS" -eq 1 ]; then
11 export MSYS2_ENV_CONV_EXCL="GIT_LFS_TEST_DIR"
12 fi
13
14 # The "git lfs env" command should ignore this environment variable
15 # despite the "GIT_" strings in its name and value.
16 export TEST_GIT_EXAMPLE="GIT_EXAMPLE"
17
18 setup_expected_concurrent_transfers
19
20 begin_test "git worktree"
21 (
22 set -e
23 reponame="worktree-main"
24 mkdirscip-shell system . . mkdir. $reponame
25 cd $reponame
26 gitscip-shell system . . git. init
27
28 # can't create a worktree until there's 1 commit at least
29 echoscip-shell system . . echo. "a" > tmp.txt
30 gitscip-shell system . . git. add tmp.txt
31 gitscip-shell system . . git. commit -m "Initial commit"
32
33 expected=$(printfscip-shell system . . printf. "%s\n%s\n
34 LocalWorkingDir=$(canonical_path_escaped "$TRASHDIR/$reponame")
35 LocalGitDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git")
36 LocalGitStorageDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git")
37 LocalMediaDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs/objects")
38 LocalReferenceDirs=
39 TempDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs/tmp")
40 ConcurrentTransfers=%d
41 TusTransfers=false
42 BasicTransfersOnly=false
43 SkipDownloadErrors=false
44 FetchRecentAlways=false
45 FetchRecentRefsDays=7
46 FetchRecentCommitsDays=0
47 FetchRecentRefsIncludeRemotes=true
48 PruneOffsetDays=3
49 PruneVerifyRemoteAlways=false
50 PruneVerifyUnreachableAlways=false
51 PruneRemoteName=origin
52 LfsStorageDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs")
53 AccessDownload=none
54 AccessUpload=none
55 DownloadTransfers=basic,lfs-standalone-file,ssh
56 UploadTransfers=basic,lfs-standalone-file,ssh
57 $(escape_path "$(envscip-shell system . . env. | grepscip-shell system . . grep. "^GIT_")")
58 %s
59 " "$(gitscip-shell system . . git. lfs version)" "$(gitscip-shell system . . git. version)" "$expectedConcurrentTransfers" "$envInitConfig")
60 actual=$(gitscip-shell system . . git. lfs env | grepscip-shell system . . grep. -v "^GIT_EXEC_PATH=")
61 contains_same_elements "$expected" "$actual"
62
63 worktreename="worktree-2"
64 gitscip-shell system . . git. worktree add "$TRASHDIR/$worktreename"
65 cd "$TRASHDIR/$worktreename"
66
67 # git dir in worktree is like submodules (except path is worktrees) but this
68 # is only for index, temp etc
69 # storage of git objects and lfs objects is in the original .git
70 expected=$(printfscip-shell system . . printf. "%s\n%s\n
71 LocalWorkingDir=$(canonical_path_escaped "$TRASHDIR/$worktreename")
72 LocalGitDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/worktrees/$worktreename")
73 LocalGitStorageDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git")
74 LocalMediaDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs/objects")
75 LocalReferenceDirs=
76 TempDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs/tmp")
77 ConcurrentTransfers=%d
78 TusTransfers=false
79 BasicTransfersOnly=false
80 SkipDownloadErrors=false
81 FetchRecentAlways=false
82 FetchRecentRefsDays=7
83 FetchRecentCommitsDays=0
84 FetchRecentRefsIncludeRemotes=true
85 PruneOffsetDays=3
86 PruneVerifyRemoteAlways=false
87 PruneVerifyUnreachableAlways=false
88 PruneRemoteName=origin
89 LfsStorageDir=$(canonical_path_escaped "$TRASHDIR/$reponame/.git/lfs")
90 AccessDownload=none
91 AccessUpload=none
92 DownloadTransfers=basic,lfs-standalone-file,ssh
93 UploadTransfers=basic,lfs-standalone-file,ssh
94 $(escape_path "$(envscip-shell system . . env. | grepscip-shell system . . grep. "^GIT_")")
95 %s
96 " "$(gitscip-shell system . . git. lfs version)" "$(gitscip-shell system . . git. version)" "$expectedConcurrentTransfers" "$envInitConfig")
97 actual=$(gitscip-shell system . . git. lfs env | grepscip-shell system . . grep. -v "^GIT_EXEC_PATH=")
98 contains_same_elements "$expected" "$actual"
99 )
100 end_test
101
102 begin_test "git worktree with hooks"
103 (
104 set -e
105 reponame="worktree-hooks"
106 mkdirscip-shell system . . mkdir. $reponame
107 cd $reponame
108 gitscip-shell system . . git. init
109
110 # can't create a worktree until there's 1 commit at least
111 echoscip-shell system . . echo. "a" > tmp.txt
112 gitscip-shell system . . git. add tmp.txt
113 gitscip-shell system . . git. commit -m "Initial commit"
114
115 worktreename="worktree-2-hook"
116 gitscip-shell system . . git. worktree add "$TRASHDIR/$worktreename"
117 cd "$TRASHDIR/$worktreename"
118
119 # No hooks so far.
120 [scip-shell system . . `[`. ! -e "$TRASHDIR/$reponame/.git/worktrees/$worktreename/hooks" ]
121 [scip-shell system . . `[`. ! -e "$TRASHDIR/$reponame/.git/hooks/pre-push" ]
122
123 gitscip-shell system . . git. lfs install
124
125 # Make sure we installed the hooks in the main repo, not the worktree dir.
126 [scip-shell system . . `[`. ! -e "$TRASHDIR/$reponame/.git/worktrees/$worktreename/hooks" ]
127 [scip-shell system . . `[`. -x "$TRASHDIR/$reponame/.git/hooks/pre-push" ]
128 )
129 end_test