cache_name_compare() compares name and stage, nothing else.
[git.git] / Documentation / git-ls-files.txt
1 git-ls-files(1)
2 ===============
3
4 NAME
5 ----
6 git-ls-files - Information about files in the index/working directory
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 'git-ls-files' [-z] [-t] [-v]
13                 (--[cached|deleted|others|ignored|stage|unmerged|killed|modified])\*
14                 (-[c|d|o|i|s|u|k|m])\*
15                 [-x <pattern>|--exclude=<pattern>]
16                 [-X <file>|--exclude-from=<file>]
17                 [--exclude-per-directory=<file>] 
18                 [--full-name] [--] [<file>]\*
19
20 DESCRIPTION
21 -----------
22 This merges the file listing in the directory cache index with the
23 actual working directory list, and shows different combinations of the
24 two.
25
26 One or more of the options below may be used to determine the files
27 shown:
28
29 OPTIONS
30 -------
31 -c|--cached::
32         Show cached files in the output (default)
33
34 -d|--deleted::
35         Show deleted files in the output
36
37 -m|--modified::
38         Show modified files in the output
39
40 -o|--others::
41         Show other files in the output
42
43 -i|--ignored::
44         Show ignored files in the output
45         Note the this also reverses any exclude list present.
46
47 -s|--stage::
48         Show stage files in the output
49
50 --directory::
51         If a whole directory is classified as "other", show just its
52         name (with a trailing slash) and not its whole contents.
53
54 -u|--unmerged::
55         Show unmerged files in the output (forces --stage)
56
57 -k|--killed::
58         Show files on the filesystem that need to be removed due
59         to file/directory conflicts for checkout-index to
60         succeed.
61
62 -z::
63         \0 line termination on output.
64
65 -x|--exclude=<pattern>::
66         Skips files matching pattern.
67         Note that pattern is a shell wildcard pattern.
68
69 -X|--exclude-from=<file>::
70         exclude patterns are read from <file>; 1 per line.
71
72 --exclude-per-directory=<file>::
73         read additional exclude patterns that apply only to the
74         directory and its subdirectories in <file>.
75
76 -t::
77         Identify the file status with the following tags (followed by
78         a space) at the start of each line:
79         H::     cached
80         M::     unmerged
81         R::     removed/deleted
82         C::     modified/changed
83         K::     to be killed
84         ?       other
85
86 -v::
87         Similar to `-t`, but use lowercase letters for files
88         that are marked as 'always matching index'.
89
90 --full-name::
91         When run from a subdirectory, the command usually
92         outputs paths relative to the current directory.  This
93         option forces paths to be output relative to the project
94         top directory.
95
96 --::
97         Do not interpret any more arguments as options.
98
99 <file>::
100         Files to show. If no files are given all files which match the other
101         specified criteria are shown.
102
103 Output
104 ------
105 show files just outputs the filename unless '--stage' is specified in
106 which case it outputs:
107
108         [<tag> ]<mode> <object> <stage> <file>
109
110 "git-ls-files --unmerged" and "git-ls-files --stage" can be used to examine
111 detailed information on unmerged paths.
112
113 For an unmerged path, instead of recording a single mode/SHA1 pair,
114 the dircache records up to three such pairs; one from tree O in stage
115 1, A in stage 2, and B in stage 3.  This information can be used by
116 the user (or the porcelain) to see what should eventually be recorded at the
117 path. (see git-read-tree for more information on state)
118
119 When `-z` option is not used, TAB, LF, and backslash characters
120 in pathnames are represented as `\t`, `\n`, and `\\`,
121 respectively.
122
123
124 Exclude Patterns
125 ----------------
126
127 'git-ls-files' can use a list of "exclude patterns" when
128 traversing the directory tree and finding files to show when the
129 flags --others or --ignored are specified.
130
131 These exclude patterns come from these places:
132
133   1. command line flag --exclude=<pattern> specifies a single
134      pattern.
135
136   2. command line flag --exclude-from=<file> specifies a list of
137      patterns stored in a file.
138
139   3. command line flag --exclude-per-directory=<name> specifies
140      a name of the file in each directory 'git-ls-files'
141      examines, and if exists, its contents are used as an
142      additional list of patterns.
143
144 An exclude pattern file used by (2) and (3) contains one pattern
145 per line.  A line that starts with a '#' can be used as comment
146 for readability.
147
148 There are three lists of patterns that are in effect at a given
149 time.  They are built and ordered in the following way:
150
151  * --exclude=<pattern> from the command line; patterns are
152    ordered in the same order as they appear on the command line.
153
154  * lines read from --exclude-from=<file>; patterns are ordered
155    in the same order as they appear in the file.
156
157  * When --exclude-per-directory=<name> is specified, upon
158    entering a directory that has such a file, its contents are
159    appended at the end of the current "list of patterns".  They
160    are popped off when leaving the directory.
161
162 Each pattern in the pattern list specifies "a match pattern" and
163 optionally the fate; either a file that matches the pattern is
164 considered excluded or included.  A filename is matched against
165 the patterns in the three lists; the --exclude-from list is
166 checked first, then the --exclude-per-directory list, and then
167 finally the --exclude list. The last match determines its fate.
168 If there is no match in the three lists, the fate is "included".
169
170 A pattern specified on the command line with --exclude or read
171 from the file specified with --exclude-from is relative to the
172 top of the directory tree.  A pattern read from a file specified
173 by --exclude-per-directory is relative to the directory that the
174 pattern file appears in.
175
176 An exclude pattern is of the following format:
177
178  - an optional prefix '!' which means that the fate this pattern
179    specifies is "include", not the usual "exclude"; the
180    remainder of the pattern string is interpreted according to
181    the following rules.
182
183  - if it does not contain a slash '/', it is a shell glob
184    pattern and used to match against the filename without
185    leading directories (i.e. the same way as the current
186    implementation).
187
188  - otherwise, it is a shell glob pattern, suitable for
189    consumption by fnmatch(3) with FNM_PATHNAME flag.  I.e. a
190    slash in the pattern must match a slash in the pathname.
191    "Documentation/\*.html" matches "Documentation/git.html" but
192    not "ppc/ppc.html".  As a natural exception, "/*.c" matches
193    "cat-file.c" but not "mozilla-sha1/sha1.c".
194
195 An example:
196
197 --------------------------------------------------------------
198     $ cat .git/ignore
199     # ignore objects and archives, anywhere in the tree.
200     *.[oa]
201     $ cat Documentation/.gitignore
202     # ignore generated html files,
203     *.html
204     # except foo.html which is maintained by hand
205     !foo.html
206     $ git-ls-files --ignored \
207         --exclude='Documentation/*.[0-9]' \
208         --exclude-from=.git/ignore \
209         --exclude-per-directory=.gitignore
210 --------------------------------------------------------------
211
212
213 See Also
214 --------
215 gitlink:git-read-tree[1]
216
217
218 Author
219 ------
220 Written by Linus Torvalds <torvalds@osdl.org>
221
222 Documentation
223 --------------
224 Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
225
226 GIT
227 ---
228 Part of the gitlink:git[7] suite
229