Commit 6bb9bb6
path-walk: support wildcard pathspecs for blob filtering
Previously, walk_objects_by_path() rejected pathspecs containing
wildcards or magic with an error ("provided pathspec is too generic").
This was overly restrictive, as wildcard pathspecs like "d/file.*.txt"
are useful for narrowing which blobs to process (e.g., during
'git backfill').
Support wildcard pathspecs by making three changes:
1. Add an 'exact_pathspecs' flag to path_walk_context. When the
pathspec has no wildcards or magic, set this flag and use the
existing fast-path prefix matching in add_tree_entries(). When
wildcards are present, skip that block since prefix matching
cannot handle glob patterns.
2. Disable revision-level commit pruning (revs->prune = 0) for
wildcard pathspecs. The revision walk uses the pathspec to filter
commits via TREESAME detection. For exact prefix pathspecs this
works well, but wildcard pathspecs may fail to match through
TREESAME because fnmatch with WM_PATHNAME does not cross directory
boundaries. Disabling pruning ensures all commits are visited and
their trees are available for the path-walk to filter.
3. Add a match_pathspec() check in walk_path() to filter out blobs
whose full path does not match the pathspec. This provides the
actual blob-level filtering for wildcard pathspecs.
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 2ef22aa commit 6bb9bb6
2 files changed
+31
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
209 | | - | |
| 211 | + | |
210 | 212 | | |
211 | 213 | | |
212 | 214 | | |
| |||
317 | 319 | | |
318 | 320 | | |
319 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
320 | 329 | | |
321 | 330 | | |
322 | 331 | | |
| |||
525 | 534 | | |
526 | 535 | | |
527 | 536 | | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | 537 | | |
533 | 538 | | |
534 | | - | |
535 | | - | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
536 | 543 | | |
537 | 544 | | |
538 | 545 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
300 | 317 | | |
301 | 318 | | |
302 | 319 | | |
| |||
0 commit comments