From 2a34b3181dba0d2049dff127ee70aca0c255a7ad Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Fri, 13 Jan 2023 04:41:51 +0000 Subject: [PATCH 1/4] ls-files: add missing documentation for --resolve-undo option ls-files' --resolve-undo option has existed ever since 9d9a2f4aba ("resolve-undo: basic tests", 2009-12-25), but was never documented. However, the option has been referred to in the ls-files manual itself ever since ce74de931d ("ls-files: introduce "--format" option", 2022-07-23), making its omission a bit jarring. Document this option. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- Documentation/git-ls-files.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 440043cdb8..cb071583f8 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -12,6 +12,7 @@ SYNOPSIS 'git ls-files' [-z] [-t] [-v] [-f] [-c|--cached] [-d|--deleted] [-o|--others] [-i|--ignored] [-s|--stage] [-u|--unmerged] [-k|--killed] [-m|--modified] + [--resolve-undo] [--directory [--no-empty-directory]] [--eol] [--deduplicate] [-x |--exclude=] @@ -77,6 +78,13 @@ OPTIONS to file/directory conflicts for checkout-index to succeed. +--resolve-undo:: + Show files having resolve-undo information in the index + together with their resolve-undo information. (resolve-undo + information is what is used to implement "git checkout -m + $PATH", i.e. to recreate merge conflicts that were + accidentally resolved) + -z:: \0 line termination on output and do not quote filenames. See OUTPUT below for more information. @@ -136,6 +144,7 @@ a space) at the start of each line: C:: modified/changed K:: to be killed ?:: other + U:: resolve-undo -- -v:: From 2b02d2df2bc38048ca70c82024834995624c2f4d Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Fri, 13 Jan 2023 04:41:52 +0000 Subject: [PATCH 2/4] 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 Signed-off-by: Junio C Hamano --- Documentation/git-ls-files.txt | 37 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index cb071583f8..f89ab1bfc9 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -29,21 +29,26 @@ This merges the file listing in the index with the actual working directory list, and shows different combinations of the two. One or more of the options below may be used to determine the files -shown: +shown, and each file may be printed multiple times if there are +multiple entries in the index or multiple statuses are applicable for +the relevant file selection options. OPTIONS ------- -c:: --cached:: - Show cached files in the output (default) + Show all files cached in Git's index, i.e. all tracked files. + (This is the default if no -c/-s/-d/-o/-u/-k/-m/--resolve-undo + options are specified.) -d:: --deleted:: - Show deleted files in the output + Show files with an unstaged deletion -m:: --modified:: - Show modified files in the output + Show files with an unstaged modification (note that an unstaged + deletion also counts as an unstaged modification) -o:: --others:: @@ -51,11 +56,14 @@ OPTIONS -i:: --ignored:: - Show only ignored files in the output. When showing files in the - index, print only those matched by an exclude pattern. When - showing "other" files, show only those matched by an exclude - pattern. Standard ignore rules are not automatically activated, - therefore at least one of the `--exclude*` options is required. + Show only ignored files in the output. Must be used with + either an explicit '-c' or '-o'. When showing files in the + index (i.e. when used with '-c'), print only those files + matching an exclude pattern. When showing "other" files + (i.e. when used with '-o'), show only those matched by an + exclude pattern. Standard ignore rules are not automatically + activated, therefore at least one of the `--exclude*` options + is required. -s:: --stage:: @@ -64,19 +72,22 @@ OPTIONS --directory:: If a whole directory is classified as "other", show just its name (with a trailing slash) and not its whole contents. + Has no effect without -o/--others. --no-empty-directory:: Do not list empty directories. Has no effect without --directory. -u:: --unmerged:: - Show unmerged files in the output (forces --stage) + Show information about unmerged files in the output, but do + not show any other tracked files (forces --stage, overrides + --cached). -k:: --killed:: - Show files on the filesystem that need to be removed due - to file/directory conflicts for checkout-index to - succeed. + Show untracked files on the filesystem that need to be removed + due to file/directory conflicts for tracked files to be able to + be written to the filesystem. --resolve-undo:: Show files having resolve-undo information in the index From 4173b806c75dbcf4406c7a5ad6158dcbfa2beb2f Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Fri, 13 Jan 2023 04:41:53 +0000 Subject: [PATCH 3/4] ls-files: clarify descriptions of status tags for -t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Much like the file selection options we tweaked in the last commit, the status tags printed with -t had descriptions that were easy to misunderstand, and for many of the same reasons. Clarify them. Also, while at it, remove the "semi-deprecated" comment for "git ls-files -t". The -t option was marked as semi-deprecated in 5bc0e247c4 ("Document ls-files -t as semi-obsolete.", 2010-07-28) because:     "git ls-files -t" is [...] badly documented, hence we point the     users to superior alternatives.     The feature is marked as "semi-obsolete" but not "scheduled for removal"     since it's a plumbing command, scripts might use it, and Git testsuite     already uses it to test the state of the index. Marking it as obsolete because it was easily misunderstood, which I think was primarily due to documentation problems, is one strategy, but I think fixing the documentation is a better option. Especially since in the intervening time, "git ls-files -t" has become heavily used by sparse-checkout users where the same confusion just doesn't apply. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- Documentation/git-ls-files.txt | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index f89ab1bfc9..3886d58d17 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -137,25 +137,27 @@ OPTIONS with `-s` or `-u` options does not make any sense. -t:: - This feature is semi-deprecated. For scripting purpose, - linkgit:git-status[1] `--porcelain` and + Show status tags together with filenames. Note that for + scripting purposes, linkgit:git-status[1] `--porcelain` and linkgit:git-diff-files[1] `--name-status` are almost always superior alternatives, and users should look at linkgit:git-status[1] `--short` or linkgit:git-diff[1] `--name-status` for more user-friendly alternatives. + -- -This option identifies the file status with the following tags (followed by -a space) at the start of each line: +This option provides a reason for showing each filename, in the form +of a status tag (which is followed by a space and then the filename). +The status tags are all single characters from the following list: - H:: cached - S:: skip-worktree - M:: unmerged - R:: removed/deleted - C:: modified/changed - K:: to be killed - ?:: other - U:: resolve-undo + H:: tracked file that is not either unmerged or skip-worktree + S:: tracked file that is skip-worktree + M:: tracked file that is unmerged + R:: tracked file with unstaged removal/deletion + C:: tracked file with unstaged modification/change + K:: untracked paths which are part of file/directory conflicts + which prevent checking out tracked files + ?:: untracked file + U:: file with resolve-undo information -- -v:: From e750951e74fc3fc2b40a8601b70cdf6e69ec6cf2 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Fri, 13 Jan 2023 04:41:54 +0000 Subject: [PATCH 4/4] ls-files: guide folks to --exclude-standard over other --exclude* options Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- Documentation/git-ls-files.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 3886d58d17..1abdd3c21c 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -119,7 +119,8 @@ OPTIONS --exclude-per-directory=:: Read additional exclude patterns that apply only to the - directory and its subdirectories in . + directory and its subdirectories in . Deprecated; use + --exclude-standard instead. --exclude-standard:: Add the standard Git exclusions: .git/info/exclude, .gitignore @@ -291,7 +292,9 @@ traversing the directory tree and finding files to show when the flags --others or --ignored are specified. linkgit:gitignore[5] specifies the format of exclude patterns. -These exclude patterns come from these places, in order: +Generally, you should just use --exclude-standard, but for historical +reasons the exclude patterns can be specified from the following +places, in order: 1. The command-line flag --exclude= specifies a single pattern. Patterns are ordered in the same order