Skip to content

Commit 2b02d2d

Browse files
newrengitster
authored andcommitted
ls-files: clarify descriptions of file selection options
The previous descriptions of the file selection options were very easy to misunderstand. For example: * "Show cached files in the output" This could be interpreted as meaning "show files which have been modified and git-add'ed, i.e. files which have cached changes relative to HEAD". * "Show deleted files" This could be interpreted as meaning "for each `git rm $FILE` we ran, show me $FILE" * "Show modified files" This could be interpreted as meaning "show files which have been modified and git-add'ed" or as "show me files that differ from HEAD" or as "show me undeleted files different from HEAD" (given that --deleted is a separate option), none of which are correct. Further, it's not very clear when some options only modify and/or override other options, as was the case with --ignored, --directory, and --unmerged (I've seen folks confused by each of them on the mailing list, sometimes even fellow git developers.) Tweak these definitions, and the one for --killed, to try to make them all a bit more clear. Finally, also clarify early on that duplicate reports for paths are often expected (both when (a) there are multiple entries for the file in the index -- i.e. when there are conflicts, and also (b) when the user specifies options that might pick the same file multiple times, such as `git ls-files --cached --deleted --modified` when there is a file with an unstaged deletion). Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2a34b31 commit 2b02d2d

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

Documentation/git-ls-files.txt

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,41 @@ This merges the file listing in the index with the actual working
2929
directory list, and shows different combinations of the two.
3030

3131
One or more of the options below may be used to determine the files
32-
shown:
32+
shown, and each file may be printed multiple times if there are
33+
multiple entries in the index or multiple statuses are applicable for
34+
the relevant file selection options.
3335

3436
OPTIONS
3537
-------
3638
-c::
3739
--cached::
38-
Show cached files in the output (default)
40+
Show all files cached in Git's index, i.e. all tracked files.
41+
(This is the default if no -c/-s/-d/-o/-u/-k/-m/--resolve-undo
42+
options are specified.)
3943

4044
-d::
4145
--deleted::
42-
Show deleted files in the output
46+
Show files with an unstaged deletion
4347

4448
-m::
4549
--modified::
46-
Show modified files in the output
50+
Show files with an unstaged modification (note that an unstaged
51+
deletion also counts as an unstaged modification)
4752

4853
-o::
4954
--others::
5055
Show other (i.e. untracked) files in the output
5156

5257
-i::
5358
--ignored::
54-
Show only ignored files in the output. When showing files in the
55-
index, print only those matched by an exclude pattern. When
56-
showing "other" files, show only those matched by an exclude
57-
pattern. Standard ignore rules are not automatically activated,
58-
therefore at least one of the `--exclude*` options is required.
59+
Show only ignored files in the output. Must be used with
60+
either an explicit '-c' or '-o'. When showing files in the
61+
index (i.e. when used with '-c'), print only those files
62+
matching an exclude pattern. When showing "other" files
63+
(i.e. when used with '-o'), show only those matched by an
64+
exclude pattern. Standard ignore rules are not automatically
65+
activated, therefore at least one of the `--exclude*` options
66+
is required.
5967

6068
-s::
6169
--stage::
@@ -64,19 +72,22 @@ OPTIONS
6472
--directory::
6573
If a whole directory is classified as "other", show just its
6674
name (with a trailing slash) and not its whole contents.
75+
Has no effect without -o/--others.
6776

6877
--no-empty-directory::
6978
Do not list empty directories. Has no effect without --directory.
7079

7180
-u::
7281
--unmerged::
73-
Show unmerged files in the output (forces --stage)
82+
Show information about unmerged files in the output, but do
83+
not show any other tracked files (forces --stage, overrides
84+
--cached).
7485

7586
-k::
7687
--killed::
77-
Show files on the filesystem that need to be removed due
78-
to file/directory conflicts for checkout-index to
79-
succeed.
88+
Show untracked files on the filesystem that need to be removed
89+
due to file/directory conflicts for tracked files to be able to
90+
be written to the filesystem.
8091

8192
--resolve-undo::
8293
Show files having resolve-undo information in the index

0 commit comments

Comments
 (0)