Debian Codegraph @

t/t-install-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 # These tests rely on behavior found in Git versions higher than 2.20.0 to
6 # perform themselves, specifically:
7 # - worktreeConfig extension support
8 ensure_git_version_isnt $VERSION_LOWER "2.20.0"
9
10 begin_test "install --worktree outside repository"
11 (
12 set -e
13
14 # If run inside the git-lfs source dir this will update its .git/config & cause issues
15 if [scip-shell system . . `[`. "$GIT_LFS_TEST_DIR" == "" ]; then
16 echoscip-shell system . . echo. "Skipping install --worktree because GIT_LFS_TEST_DIR is not set"
17 exit 0
18 fi
19
20 has_test_dir || exit 0
21
22 set +e
23 gitscip-shell system . . git. lfs install --worktree >out.log
24 res=$?
25 set -e
26
27 [scip-shell system . . `[`. "Not in a Git repository." = "$(catscip-shell system . . cat. out.log)" ]
28 [scip-shell system . . `[`. "0" != "$res" ]
29 )
30 end_test
31
32 begin_test "install --worktree with single working tree"
33 (
34 set -e
35
36 # old values that should be ignored by `install --worktree`
37 gitscip-shell system . . git. config --global filter.lfs.smudge "global smudge"
38 gitscip-shell system . . git. config --global filter.lfs.clean "global clean"
39 gitscip-shell system . . git. config --global filter.lfs.process "global filter"
40
41 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-single-tree"
42 mkdirscip-shell system . . mkdir. "$reponame"
43 cd "$reponame"
44 gitscip-shell system . . git. init
45 gitscip-shell system . . git. lfs install --worktree
46
47 # local configs are correct
48 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
49 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config --local filter.lfs.smudge)" ]
50 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config --worktree filter.lfs.smudge)" ]
51 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
52 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config --local filter.lfs.clean)" ]
53 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config --worktree filter.lfs.clean)" ]
54 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
55 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config --local filter.lfs.process)" ]
56 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config --worktree filter.lfs.process)" ]
57
58 # global configs
59 [scip-shell system . . `[`. "global smudge" = "$(gitscip-shell system . . git. config --global filter.lfs.smudge)" ]
60 [scip-shell system . . `[`. "global clean" = "$(gitscip-shell system . . git. config --global filter.lfs.clean)" ]
61 [scip-shell system . . `[`. "global filter" = "$(gitscip-shell system . . git. config --global filter.lfs.process)" ]
62 )
63 end_test
64
65 begin_test "install --worktree with multiple working trees"
66 (
67 set -e
68
69 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-multi-tree"
70 mkdirscip-shell system . . mkdir. "$reponame"
71 cd "$reponame"
72 gitscip-shell system . . git. init
73
74 # old values that should be ignored by `install --worktree`
75 gitscip-shell system . . git. config --global filter.lfs.smudge "global smudge"
76 gitscip-shell system . . git. config --global filter.lfs.clean "global clean"
77 gitscip-shell system . . git. config --global filter.lfs.process "global filter"
78 gitscip-shell system . . git. config --local filter.lfs.smudge "local smudge"
79 gitscip-shell system . . git. config --local filter.lfs.clean "local clean"
80 gitscip-shell system . . git. config --local filter.lfs.process "local filter"
81
82 touchscip-shell system . . touch. a.txt
83 gitscip-shell system . . git. add a.txt
84 gitscip-shell system . . git. commit -m "initial commit"
85
86 gitscip-shell system . . git. config core.repositoryformatversion 1
87 gitscip-shell system . . git. config extensions.worktreeConfig true
88
89 treename="../$reponame-wt"
90 gitscip-shell system . . git. worktree add "$treename"
91 cd "$treename"
92
93 gitscip-shell system . . git. lfs install --worktree
94
95 # worktree configs are correct
96 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config filter.lfs.smudge)" ]
97 [scip-shell system . . `[`. "git-lfs smudge -- %f" = "$(gitscip-shell system . . git. config --worktree filter.lfs.smudge)" ]
98 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config filter.lfs.clean)" ]
99 [scip-shell system . . `[`. "git-lfs clean -- %f" = "$(gitscip-shell system . . git. config --worktree filter.lfs.clean)" ]
100 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config filter.lfs.process)" ]
101 [scip-shell system . . `[`. "git-lfs filter-process" = "$(gitscip-shell system . . git. config --worktree filter.lfs.process)" ]
102
103 # local configs are correct
104 [scip-shell system . . `[`. "local smudge" = "$(gitscip-shell system . . git. config --local filter.lfs.smudge)" ]
105 [scip-shell system . . `[`. "local clean" = "$(gitscip-shell system . . git. config --local filter.lfs.clean)" ]
106 [scip-shell system . . `[`. "local filter" = "$(gitscip-shell system . . git. config --local filter.lfs.process)" ]
107
108 # global configs
109 [scip-shell system . . `[`. "global smudge" = "$(gitscip-shell system . . git. config --global filter.lfs.smudge)" ]
110 [scip-shell system . . `[`. "global clean" = "$(gitscip-shell system . . git. config --global filter.lfs.clean)" ]
111 [scip-shell system . . `[`. "global filter" = "$(gitscip-shell system . . git. config --global filter.lfs.process)" ]
112 )
113 end_test
114
115 begin_test "install --worktree without worktreeConfig extension"
116 (
117 set -e
118
119 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-multi-tree-no-config"
120 mkdirscip-shell system . . mkdir. "$reponame"
121 cd "$reponame"
122 gitscip-shell system . . git. init
123
124 touchscip-shell system . . touch. a.txt
125 gitscip-shell system . . git. add a.txt
126 gitscip-shell system . . git. commit -m "initial commit"
127
128 treename="../$reponame-wt"
129 gitscip-shell system . . git. worktree add "$treename"
130 cd "$treename"
131
132 set +e
133 gitscip-shell system . . git. lfs install --worktree >out.log
134 res=$?
135 set -e
136
137 catscip-shell system . . cat. out.log
138 grepscip-shell system . . grep. -E "error running.*git.*config" out.log
139 [scip-shell system . . `[`. "$res" -eq 2 ]
140 )
141 end_test
142
143 begin_test "install --worktree with conflicting scope"
144 (
145 set -e
146
147 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")-scope-conflict"
148 mkdirscip-shell system . . mkdir. "$reponame"
149 cd "$reponame"
150 gitscip-shell system . . git. init
151
152 set +e
153 gitscip-shell system . . git. lfs install --local --worktree 2>err.log
154 res=$?
155 set -e
156
157 [scip-shell system . . `[`. "Only one of the --local, --system, --worktree, and --file options can be specified." = "$(catscip-shell system . . cat. err.log)" ]
158 [scip-shell system . . `[`. "0" != "$res" ]
159
160 set +e
161 gitscip-shell system . . git. lfs install --worktree --system 2>err.log
162 res=$?
163 set -e
164
165 [scip-shell system . . `[`. "Only one of the --local, --system, --worktree, and --file options can be specified." = "$(catscip-shell system . . cat. err.log)" ]
166 [scip-shell system . . `[`. "0" != "$res" ]
167
168 set +e
169 gitscip-shell system . . git. lfs install --worktree --file test-file 2>err.log
170 res=$?
171 set -e
172
173 [scip-shell system . . `[`. "Only one of the --local, --system, --worktree, and --file options can be specified." = "$(catscip-shell system . . cat. err.log)" ]
174 [scip-shell system . . `[`. "0" != "$res" ]
175 )
176 end_test