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.