git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Thomas Haller <thaller@redhat.com>, git@vger.kernel.org
Subject: Re: [bug] git-ls-files sometimes does not list files with pathspec magic ":(exclude)"
Date: Thu, 14 Jan 2021 15:21:14 -0500	[thread overview]
Message-ID: <YACnuuQ9ezo6Bb9H@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqa6tc1dab.fsf@gitster.c.googlers.com>

On Wed, Jan 13, 2021 at 06:07:56PM -0800, Junio C Hamano wrote:

> The rule IIUC is that a path must match one of the positive pathspec
> and none of the negative pathspec, but it looks as if there is some
> bogus optimization based on string length.

I dug a little on this earlier this morning, but didn't get far enough
to have any confidence that I wasn't barking totally up the wrong tree.
But I found the way the "prefix" is passed match_pathspec to be
confusing. This seems to make the problem go away:

diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index c8eae899b8..93796404bd 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -232,7 +232,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir,
 	    is_submodule_active(repo, ce->name)) {
 		show_submodule(repo, dir, ce->name);
 	} else if (match_pathspec(repo->index, &pathspec, fullname, strlen(fullname),
-				  max_prefix_len, ps_matched,
+				  0, ps_matched,
 				  S_ISDIR(ce->ce_mode) ||
 				  S_ISGITLINK(ce->ce_mode))) {
 		tag = get_tag(ce, tag);

which I guess is likewise disabling the same optimization you're talking
about. But that probably means the bug is in match_pathspec().

(I probably won't look further at this for a while, so please continue
your prodding; I just wanted to drop what little knowledge I came up
with).

-Peff

      reply	other threads:[~2021-01-14 20:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13 17:41 [bug] git-ls-files sometimes does not list files with pathspec magic ":(exclude)" Thomas Haller
2021-01-14  2:07 ` Junio C Hamano
2021-01-14 20:21   ` Jeff King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YACnuuQ9ezo6Bb9H@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=thaller@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).