From: Diogo Castro Date: Mon, 31 Aug 2026 14:30:22 GMT Subject: Re: [PATCH] dir: fix negative pathspecs in 'git ls-files' and 'git add' Message-ID: In-Reply-To: I think there's some misunderstanding, please allow me to take a step back and attempt to clarify. My previous message was a reply to this: > I am wondering if the solution is to compute common prefix across both positive and negative ones instead. As far as I can tell, this "common prefix" feature does not affect the semantics of "ls-files" or "add", it doesn't affect which files are reported. It only affects the performance. Your first example of "git ls-files -- a/b/c a/b/d :!a/b/" already works correctly, the pattern ":!a/b/" excludes everything from the first 2 pathspecs. So the discussion to be had is purely about performance. My point was that computing the common prefix across both positive *and* negative pathspecs would not improve performance, and might actually make it worse. The "common prefix" is mainly used to avoid walking the entire working directory. A couple of examples to illustrate: * "git add -- a/b/c a/b/d ':!a/b/x'" * Under the current implementation, the common prefix is "a/b/", so as a performance optimization, we can look only into the "a/b/" directory and ignore the others. * Under your proposal of computing the "common prefix across both positive and negative ones", the common prefix would still be "a/b/", so performance wouldn't be affected. * "git add -- a/b/c a/b/d ':!a/**/x'" * Under the current implementation, the common prefix is "a/b/", like in the example above. * Under your proposal, the common prefix would be "a/", so we'd have to walk _more_ directories, which would hurt performance. Does that answer your question? Or perhaps I misunderstood your point?