git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 0/3] dir: fix pathspec prefixes with exclusions

From
Yannik Tausch <dev@ytausch.de>
Date
Sep 3, 2026, 18:43 UTC
Message-ID
<887D6D84-F76E-4DCB-9633-CD78DA02BCC5@ytausch.de>
In-Reply-To
<886A25E6-8854-4AF6-BF0B-CFB57B673026@ytausch.de>

Pathspec prefix optimization must account for exclude items separately. The prefix is derived from non-exclude items, so applying it while matching an exclude item can compare the wrong portions of the paths. Conversely, an exclude item at the start of the pathspec currently prevents finding a common prefix among the remaining items.

The first patch, authored by Junio, marks the immutable strings in a pathspec item as const. The second patch matches exclude items against the full pathname. The third patch finds the common prefix starting with the first non-exclude item and returns both the prefix length and the string from which it was derived.

Changes since v2:
* Add Junio's preparatory const-correctness patch, which also fixes the unit
  test build with DEVELOPER=1.
* Keep the two pathspec prefix fixes unchanged.
Junio C Hamano (1):
  pathspec: match and original in pathspec_item are const
Yannik Tausch (2):
  dir: do not apply prefix to negative pathspecs
  dir: find common prefix among non-exclude pathspec items
 dir.c                       | 39 +++++++++++++++++++++----------------
 pathspec.c                  |  4 ++--
 pathspec.h                  |  4 ++--
 t/t6132-pathspec-exclude.sh |  9 +++++++++
 t/unit-tests/u-dir.c        | 28 ++++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 21 deletions(-)

Range-diff against v2: -: ---------- > 1: a257ce081e pathspec: match and original in pathspec_item are const 1: c8a2f1e22e = 2: 16c6df5080 dir: do not apply prefix to negative pathspecs 2: d0e08fdb96 = 3: b05b77f399 dir: find common prefix among non-exclude pathspec items

-- 
2.55.0
Previous: Yannik TauschNext: Yannik Tausch
Message 21 of 29 in “dir: find common prefix among positive pathspecs”
  1. dir: find common prefix among positive pathspecsYannik Tausch, Sep 2, 2026
  2. Junio C HamanoSep 2, 2026
  3. Yannik TauschSep 3, 2026
  4. 0/2 dir: fix pathspec prefixes with exclusionsYannik Tausch, Sep 3, 2026
  5. 1/2 dir: do not apply prefix to negative pathspecsYannik Tausch, Sep 3, 2026
  6. Elijah NewrenSep 4, 2026
  7. Junio C HamanoSep 4, 2026
  8. 2/2 dir: find common prefix among non-exclude pathspec itemsYannik Tausch, Sep 3, 2026
  9. Junio C HamanoSep 3, 2026
  10. pathspec: match and original in pathspec_item are constJunio C Hamano, Sep 3, 2026
  11. Yannik TauschSep 3, 2026
  12. Junio C HamanoSep 3, 2026
  13. Yannik TauschSep 3, 2026
  14. Junio C HamanoSep 3, 2026
  15. Yannik TauschSep 3, 2026
  16. Elijah NewrenSep 4, 2026
  17. Junio C HamanoSep 4, 2026
  18. Elijah NewrenSep 4, 2026
  19. Junio C HamanoSep 5, 2026
  20. Yannik TauschSep 3, 2026
  21. 0/3 dir: fix pathspec prefixes with exclusionsYannik Tausch, Sep 3, 2026
  22. 1/3 pathspec: match and original in pathspec_item are constYannik Tausch, Sep 3, 2026
  23. 2/3 dir: do not apply prefix to negative pathspecsYannik Tausch, Sep 3, 2026
  24. 3/3 dir: find common prefix among non-exclude pathspec itemsYannik Tausch, Sep 3, 2026
  25. 0/2 dir: fix pathspec prefixes with exclusionsYannik Tausch, Sep 14, 2026
  26. 1/2 dir: do not apply prefix to negative pathspecsYannik Tausch, Sep 14, 2026
  27. 2/2 dir: preserve pathspec prefix optimization with leading excludesYannik Tausch, Sep 14, 2026
  28. Junio C HamanoSep 16, 2026
  29. Yannik TauschSep 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.