t8001/t8002: blame: add tests of -L line numbers less than 1
[git.git] / Documentation / git-check-ignore.txt
blobd2df487aa20a89264afee08bcdddf681d7701fda
1 git-check-ignore(1)
2 ===================
4 NAME
5 ----
6 git-check-ignore - Debug gitignore / exclude files
9 SYNOPSIS
10 --------
11 [verse]
12 'git check-ignore' [options] pathname...
13 'git check-ignore' [options] --stdin < <list-of-paths>
15 DESCRIPTION
16 -----------
18 For each pathname given via the command-line or from a file via
19 `--stdin`, show the pattern from .gitignore (or other input files to
20 the exclude mechanism) that decides if the pathname is excluded or
21 included.  Later patterns within a file take precedence over earlier
22 ones.
24 OPTIONS
25 -------
26 -q, --quiet::
27         Don't output anything, just set exit status.  This is only
28         valid with a single pathname.
30 -v, --verbose::
31         Also output details about the matching pattern (if any)
32         for each given pathname.
34 --stdin::
35         Read file names from stdin instead of from the command-line.
37 -z::
38         The output format is modified to be machine-parseable (see
39         below).  If `--stdin` is also given, input paths are separated
40         with a NUL character instead of a linefeed character.
42 -n, --non-matching::
43         Show given paths which don't match any pattern.  This only
44         makes sense when `--verbose` is enabled, otherwise it would
45         not be possible to distinguish between paths which match a
46         pattern and those which don't.
48 OUTPUT
49 ------
51 By default, any of the given pathnames which match an ignore pattern
52 will be output, one per line.  If no pattern matches a given path,
53 nothing will be output for that path; this means that path will not be
54 ignored.
56 If `--verbose` is specified, the output is a series of lines of the form:
58 <source> <COLON> <linenum> <COLON> <pattern> <HT> <pathname>
60 <pathname> is the path of a file being queried, <pattern> is the
61 matching pattern, <source> is the pattern's source file, and <linenum>
62 is the line number of the pattern within that source.  If the pattern
63 contained a `!` prefix or `/` suffix, it will be preserved in the
64 output.  <source> will be an absolute path when referring to the file
65 configured by `core.excludesfile`, or relative to the repository root
66 when referring to `.git/info/exclude` or a per-directory exclude file.
68 If `-z` is specified, the pathnames in the output are delimited by the
69 null character; if `--verbose` is also specified then null characters
70 are also used instead of colons and hard tabs:
72 <source> <NULL> <linenum> <NULL> <pattern> <NULL> <pathname> <NULL>
74 If `-n` or `--non-matching` are specified, non-matching pathnames will
75 also be output, in which case all fields in each output record except
76 for <pathname> will be empty.  This can be useful when running
77 non-interactively, so that files can be incrementally streamed to
78 STDIN of a long-running check-ignore process, and for each of these
79 files, STDOUT will indicate whether that file matched a pattern or
80 not.  (Without this option, it would be impossible to tell whether the
81 absence of output for a given file meant that it didn't match any
82 pattern, or that the output hadn't been generated yet.)
84 Buffering happens as documented under the `GIT_FLUSH` option in
85 linkgit:git[1].  The caller is responsible for avoiding deadlocks
86 caused by overfilling an input buffer or reading from an empty output
87 buffer.
89 EXIT STATUS
90 -----------
92 0::
93         One or more of the provided paths is ignored.
95 1::
96         None of the provided paths are ignored.
98 128::
99         A fatal error was encountered.
101 SEE ALSO
102 --------
103 linkgit:gitignore[5]
104 linkgit:gitconfig[5]
105 linkgit:git-ls-files[1]
109 Part of the linkgit:git[1] suite