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

Re: [PATCH] dir: fix negative pathspecs in 'git ls-files' and 'git add'

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 28, 2026, 21:37 UTC
Message-ID
<xmqqwlta2agt.fsf@gitster.g>
In-Reply-To
<pull.2391.git.git.1787949348110.gitgitgadget@gmail.com>
"Diogo Castro via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 8 quoted lines
> From: Diogo Castro <dc@diogocastro.com>
>
> `git ls-files` calls `common_prefix()` / `get_common_prefix_len()` which
> calculate the length of the common prefix of all *positive* pathspecs,
> `max_prefix_len`.
> ...
> Solution: in `do_match_pathspec()`, only strip the prefix when handling
> positive pathspecs, not when handling negative pathspecs.
Hmph, if the command line were
	git ls-files -- a/b/c a/b/d !a/b/

shouldn't we strip a/b/ from all three? Would it make sense to leave the negative one relative to the full tree? I am wondering if the solution is to compute common prefix across both positive and negative ones instead.

Previous: Diogo Castro via GitGitGadgetNext: Diogo Castro
Message 2 of 7 in “dir: fix negative pathspecs in 'git ls-files' and 'git add'”
  1. dir: fix negative pathspecs in 'git ls-files' and 'git add'Diogo Castro via GitGitGadget, Aug 28, 2026
  2. Junio C HamanoAug 28, 2026
  3. Diogo CastroAug 30, 2026
  4. Junio C HamanoAug 30, 2026
  5. Diogo CastroAug 31, 2026
  6. Junio C HamanoAug 31, 2026
  7. Diogo CastroOct 2, 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.