git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] check-ignore: fix documentation and implementation to match

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 18, 2020, 21:27 UTC
Message-ID
<xmqqlfozio1o.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<pull.711.v2.git.git.1582058162095.gitgitgadget@gmail.com>
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 30 quoted lines
> 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.
Show 11 quoted lines
> 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.
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 8 of 9 in “check-ignore: fix handling with negated patterns”
  1. check-ignore: fix handling with negated patternsElijah Newren via GitGitGadget, Feb 17, 2020
  2. Junio C HamanoFeb 17, 2020
  3. Elijah NewrenFeb 17, 2020
  4. Junio C HamanoFeb 17, 2020
  5. Elijah NewrenFeb 17, 2020
  6. Junio C HamanoFeb 19, 2020
  7. check-ignore: fix documentation and implementation to matchElijah Newren via GitGitGadget, Feb 18, 2020
  8. Junio C HamanoFeb 18, 2020
  9. check-ignore: fix documentation and implementation to matchElijah Newren via GitGitGadget, Feb 18, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.