git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH v2] check-ignore: fix documentation and implementation to match
Date: Tue, 18 Feb 2020 13:27:31 -0800	[thread overview]
Message-ID: <xmqqlfozio1o.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <pull.711.v2.git.git.1582058162095.gitgitgadget@gmail.com> (Elijah Newren via GitGitGadget's message of "Tue, 18 Feb 2020 20:36:01 +0000")

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Since the second mode exists to find out which pattern matches given
> paths, and showing the user a pattern that begins with a '!' is
> sufficient for them to figure out whether the pattern is excluded, the
> existing behavior is desirable -- we just need to update the
> documentation to match the implementation (i.e. it is about printing
> which pattern is matched by paths, not about showing which paths are
> excluded).
>
> For the first or default mode, users just want to know whether a pattern
> is excluded.  As such, the existing documentation is desirable; change
> the implementation to match the documented behavior.
>
> Finally, also adjust a few tests in t0008 that were caught up by this
> discrepancy in how negated paths were handled.
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ...
> diff --git a/Documentation/git-check-ignore.txt b/Documentation/git-check-ignore.txt
> index 8b2d49c79e1..85ef46e2eff 100644
> --- a/Documentation/git-check-ignore.txt
> +++ b/Documentation/git-check-ignore.txt
> @@ -30,9 +30,15 @@ OPTIONS
>  	valid with a single pathname.
>  
>  -v, --verbose::
> -	Also output details about the matching pattern (if any)
> -	for each given pathname. For precedence rules within and
> -	between exclude sources, see linkgit:gitignore[5].
> +	Instead of printing the paths that are excluded, for each path
> +	that matches an exclude pattern print the exclude pattern

s/pattern print/pattern, print/;

> +	together with the path.  (Matching an exclude pattern usually
> +	means the path is excluded, but if the pattern begins with '!'
> +	then it is a negated pattern and matching it means the path is
> +	NOT excluded.)

Nicely and clearly written.

> diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
> index 5a4f92395f3..ea5d0ae3a6a 100644
> --- a/builtin/check-ignore.c
> +++ b/builtin/check-ignore.c
> @@ -108,6 +108,9 @@ static int check_ignore(struct dir_struct *dir,
>  			int dtype = DT_UNKNOWN;
>  			pattern = last_matching_pattern(dir, &the_index,
>  							full_path, &dtype);
> +			if (!verbose && pattern &&
> +			    pattern->flags & PATTERN_FLAG_NEGATIVE)
> +				pattern = NULL;

OK.

Thanks.  Will queue.

  reply	other threads:[~2020-02-18 21:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 16:15 [PATCH] check-ignore: fix handling with negated patterns Elijah Newren via GitGitGadget
2020-02-17 18:04 ` Junio C Hamano
2020-02-17 18:41   ` Elijah Newren
2020-02-17 20:41     ` Junio C Hamano
2020-02-17 21:07       ` Elijah Newren
2020-02-19 21:36         ` Junio C Hamano
2020-02-18 20:36 ` [PATCH v2] check-ignore: fix documentation and implementation to match Elijah Newren via GitGitGadget
2020-02-18 21:27   ` Junio C Hamano [this message]
2020-02-18 23:05   ` [PATCH v3] " Elijah Newren via GitGitGadget

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=xmqqlfozio1o.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=newren@gmail.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).