Commit 79b6e9a
committed
sparse-checkout: write escaped patterns in cone mode
If a user somehow creates a directory with an asterisk (*) or backslash
(\), then the "git sparse-checkout set" command will struggle to provide
the correct pattern in the sparse-checkout file. When not in cone mode,
the provided pattern is written directly into the sparse-checkout file.
However, in cone mode we expect a list of paths to directories and then
we convert those into patterns.
Even more specifically, the goal is to always allow the following from
the root of a repo:
git ls-tree --name-only -d HEAD | git sparse-checkout set --stdin
The ls-tree command provides directory names with an unescaped asterisk.
It also quotes the directories that contain an escaped backslash. We
must remove these quotes, then keep the escaped backslashes.
However, there is some care needed for the timing of these escapes. The
in-memory pattern list is used to update the working directory before
writing the patterns to disk. Thus, we need the command to have the
unescaped names in the hashsets for the cone comparisons, then escape
the patterns later.
Signed-off-by: Derrick Stolee <[email protected]>1 parent 09dbe1f commit 79b6e9a
2 files changed
+64
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
143 | 159 | | |
144 | 160 | | |
145 | 161 | | |
| |||
164 | 180 | | |
165 | 181 | | |
166 | 182 | | |
167 | | - | |
| 183 | + | |
168 | 184 | | |
169 | 185 | | |
170 | 186 | | |
| 187 | + | |
171 | 188 | | |
172 | 189 | | |
173 | 190 | | |
| |||
185 | 202 | | |
186 | 203 | | |
187 | 204 | | |
188 | | - | |
| 205 | + | |
189 | 206 | | |
| 207 | + | |
190 | 208 | | |
191 | 209 | | |
192 | 210 | | |
| |||
337 | 355 | | |
338 | 356 | | |
339 | 357 | | |
340 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
341 | 361 | | |
342 | 362 | | |
343 | 363 | | |
| |||
369 | 389 | | |
370 | 390 | | |
371 | 391 | | |
| 392 | + | |
372 | 393 | | |
373 | 394 | | |
374 | 395 | | |
375 | 396 | | |
376 | 397 | | |
377 | 398 | | |
378 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
379 | 421 | | |
380 | 422 | | |
381 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
312 | 315 | | |
313 | 316 | | |
314 | 317 | | |
| |||
379 | 382 | | |
380 | 383 | | |
381 | 384 | | |
382 | | - | |
| 385 | + | |
| 386 | + | |
383 | 387 | | |
384 | 388 | | |
385 | 389 | | |
| 390 | + | |
386 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
387 | 403 | | |
388 | 404 | | |
389 | | - | |
| 405 | + | |
| 406 | + | |
390 | 407 | | |
391 | 408 | | |
392 | 409 | | |
0 commit comments