Re: [PATCH v2 14/14] Add git-check-ignore sub-command

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

 



On 09/20/2012 09:46 PM, Adam Spiers wrote:
> This works in a similar manner to git-check-attr.  Some code
> was reused from add.c by refactoring out into pathspec.c.
> 
> Thanks to Jeff King and Junio C Hamano for the idea:
> http://thread.gmane.org/gmane.comp.version-control.git/108671/focus=108815
> 
> Signed-off-by: Adam Spiers <git@xxxxxxxxxxxxxx>
> ---
>  .gitignore                             |   1 +
>  Documentation/git-check-ignore.txt     |  85 +++++
>  Documentation/gitignore.txt            |   6 +-
>  Makefile                               |   1 +
>  builtin.h                              |   1 +
>  builtin/check-ignore.c                 | 167 ++++++++++
>  command-list.txt                       |   1 +
>  contrib/completion/git-completion.bash |   1 +
>  git.c                                  |   1 +
>  t/t0007-ignores.sh                     | 587 +++++++++++++++++++++++++++++++++
>  t/t9902-completion.sh                  |  24 +-
>  11 files changed, 861 insertions(+), 14 deletions(-)
>  create mode 100644 Documentation/git-check-ignore.txt
>  create mode 100644 builtin/check-ignore.c
>  create mode 100755 t/t0007-ignores.sh
> 
> diff --git a/.gitignore b/.gitignore
> index a188a82..11cd975 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -22,6 +22,7 @@
>  /git-bundle
>  /git-cat-file
>  /git-check-attr
> +/git-check-ignore
>  /git-check-ref-format
>  /git-checkout
>  /git-checkout-index
> diff --git a/Documentation/git-check-ignore.txt b/Documentation/git-check-ignore.txt
> new file mode 100644
> index 0000000..2de4e17
> --- /dev/null
> +++ b/Documentation/git-check-ignore.txt
> @@ -0,0 +1,85 @@
> +git-check-ignore(1)
> +=================
> +
> +NAME
> +----
> +git-check-ignore - Debug gitignore / exclude files
> +
> +
> +SYNOPSIS
> +--------
> +[verse]
> +'git check-ignore' [options] pathname...
> +'git check-ignore' [options] --stdin < <list-of-paths>
> +
> +DESCRIPTION
> +-----------
> +
> +For each pathname given via the command-line or from a file via
> +`--stdin`, this command will list the first exclude pattern found (if
> +any) which explicitly excludes or includes that pathname.  Note that
> +within any given exclude file, later patterns take precedence over
> +earlier ones, so any matching pattern which this command outputs may
> +not be the one you would immediately expect.

Can I tell from the output of "git check-ignore" whether a file is
really ignored?  The way I read the paragraph above, the output doesn't
necessarily show the pattern that determines whether a file is *really*
ignored.  That makes it sound like the ignore status of the file might
be different than what I would infer from the output.  If I am
misunderstanding the situation, then perhaps the explanation in the
above paragraph can be improved.

On the other hand, if my understanding is correct, then why did you
choose this (seemingly strange) policy?  It would seem more useful
either to output the pattern that has the definitive effect on the
file's status, or to output all patterns that match the file.

> +OPTIONS
> +-------
> +-q, --quiet::
> +	Don't output anything, just set exit status.  This is only
> +	valid with a single pathname.
> +
> +-v, --verbose::
> +	Also output details about the matching pattern (if any)
> +	for each given pathname.
> +
> +--stdin::
> +	Read file names from stdin instead of from the command-line.
> +
> +-z::
> +	The output format is modified to be machine-parseable (see
> +	below).  If `--stdin` is also given, input paths are separated
> +	with a NUL character instead of a linefeed character.
> +
> +OUTPUT
> +------
> +
> +By default, any of the given pathnames which match an ignore pattern
> +will be output, one per line.  If no pattern matches a given path,
> +nothing will be output for that path; this means that path will not be
> +ignored.
> +
> +If `--verbose` is specified, the output is a series of lines of the form:
> +
> +<source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
> +
> +<pathname> is the path of a file being queried, <pattern> is the
> +matching pattern, <source> is the pattern's source file, and <linenum>
> +is the line number of the pattern within that source.  If the pattern
> +contained a `!` prefix or `/` suffix, it will be preserved in the
> +output.  <source> will be an absolute path when referring to the file
> +configured by `core.excludesfile`, or relative to the repository root
> +when referring to `.git/info/exclude` or a per-directory exclude file.
> +
> +If `-z` is specified, the output is a series of lines of the form:
> +
> +EXIT STATUS
> +-----------
> [...]

I think you forgot to finish the thought about "If -z is specified".

Michael

-- 
Michael Haggerty
mhagger@xxxxxxxxxxxx
http://softwareswirl.blogspot.com/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]