public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Remy D. Farley" <one-d-wide@protonmail.com>
Cc: git@vger.kernel.org,  Tian Yuchen <a3205153416@gmail.com>
Subject: Re: [PATCH] fix git add :!x exiting with error when x is in .gitignore
Date: Wed, 04 Feb 2026 08:48:59 -0800	[thread overview]
Message-ID: <xmqqo6m4pi84.fsf@gitster.g> (raw)
In-Reply-To: <20260204132747.1564157-1-one-d-wide@protonmail.com> (Remy D. Farley's message of "Wed, 04 Feb 2026 13:30:38 +0000")

"Remy D. Farley" <one-d-wide@protonmail.com> writes:

> diff --git a/dir.c b/dir.c
> index b00821f294..ed6b99e337 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -2280,6 +2280,9 @@ static int exclude_matches_pathspec(const char *path, int pathlen,
>  		const struct pathspec_item *item = &pathspec->items[i];
>  		int len = item->nowildcard_len;
>  
> +		if (item->magic & PATHSPEC_EXCLUDE)
> +			continue;
> +
>  		if (len == pathlen &&
>  		    !ps_strncmp(item, item->match, path, pathlen))
>  			return 1;

A question that immediately comes to mind is if it is appropriate
for a negated pathspec element to recuse itself like this from the
decision process and let other pathspec elements decide the fate of
the path, or if a negated pathspec element should take a more active
role of saying "no" (no, not by immediately returning 0, but this
loop may have to become a two step process if we wanted to implement
e.g., for the function to yield "yes", it has to match at least one
positive pathspec element and zero negated one, or something like
that).

What should

	git add "$x" ":!$y"

do when a path <matches, does not match> $X and <matches, does not
match> $Y?  We have four combinations to consider in such a case.
The code in the patch says it should behave identically to

	git add "$x"

and negated ":!$y" should not make any difference.  Is that what we
want?

Thanks.

  reply	other threads:[~2026-02-04 16:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04 13:30 [PATCH] fix git add :!x exiting with error when x is in .gitignore Remy D. Farley
2026-02-04 16:48 ` Junio C Hamano [this message]
2026-02-04 17:53   ` Tian Yuchen
2026-02-04 18:47     ` Junio C Hamano
2026-02-04 20:11       ` Remy D. Farley
2026-02-04 20:47         ` Junio C Hamano

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

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

  git send-email \
    --in-reply-to=xmqqo6m4pi84.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=a3205153416@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=one-d-wide@protonmail.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox