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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Elijah Newren via GitGitGadget" <gitgitgadget@xxxxxxxxx> 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@xxxxxxxxx>
> ...
> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux