grep docs: describe --no-index further and improve formatting a bit

Improve the description of --no-index, to make it more clear to the users what this option actually does under the hood, and what's its purpose. Describe the dependency between --no-index and either of the --cached and --untracked options, which cannot be used together. As part of that, shuffle a couple of the options, to make the documentation flow a bit better, because it makes more sense to describe first the options that have something in common, and to after that describe an option that does something differently. In more detail, --cached and --untracked both leave git-grep(1) in the usual state, in which it treats the directory as a local git repository, unlike --no-index that makes git-grep(1) treat the directory not as a git repository. While there, improve the descriptions of grep worker threads a bit, to give them better context. Adjust the language a bit, to avoid addressing the reader directly, which is in general preferred in technical documentation, because it eliminates the possible element of persuading the user to do something. In other words, we should be telling the user what our software can do, instead of telling the user what to do. Also perform some minor formatting improvements, to make it clear it's the git commands, command parameters, and configuration option names. Signed-off-by: Dragan Simic <dsimic@manjaro.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Dragan Simic committed Mar 25, 2024 at 21:34 UTC 6e9ef296e2210260852391186ba3fc411fa5b08a
1 file changed +17 -9
Documentation/git-grep.txt
+17 -9
@@ -28,7 +28,7 @@ SYNOPSIS
28 [-f <file>] [-e] <pattern>
29 [--and|--or|--not|(|)|-e <pattern>...]
30 [--recurse-submodules] [--parent-basename <basename>]
31 - [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | <tree>...]
31 + [ [--[no-]exclude-standard] [--cached | --untracked | --no-index] | <tree>...]
32 [--] [<pathspec>...]
33
34 DESCRIPTION
@@ -45,13 +45,21 @@ OPTIONS
45 Instead of searching tracked files in the working tree, search
46 blobs registered in the index file.
47
48 ---no-index::
49 - Search files in the current directory that is not managed by Git.
50 -
48 --untracked::
49 In addition to searching in the tracked files in the working
50 tree, search also in untracked files.
51
52 +--no-index::
53 + Search files in the current directory that is not managed by Git,
54 + or by ignoring that the current directory is managed by Git. This
55 + is rather similar to running the regular `grep(1)` utility with its
56 + `-r` option specified, but with some additional benefits, such as
57 + using pathspec patterns to limit paths; see the 'pathspec' entry
58 + in linkgit:gitglossary[7] for more information.
59 ++
60 +This option cannot be used together with `--cached` or `--untracked`.
61 +See also `grep.fallbackToNoIndex` in 'CONFIGURATION' below.
62 +
63 --no-exclude-standard::
64 Also search in ignored files by not honoring the `.gitignore`
65 mechanism. Only useful with `--untracked`.
@@ -248,8 +256,8 @@ providing this option will cause it to die.
256 a non-zero status.
257
258 --threads <num>::
251 - Number of grep worker threads to use.
252 - See `grep.threads` in 'CONFIGURATION' for more information.
259 + Number of `grep` worker threads to use. See 'NOTES ON THREADS'
260 + and `grep.threads` in 'CONFIGURATION' for more information.
261
262 -f <file>::
263 Read patterns from <file>, one per line.
@@ -336,9 +344,9 @@ The `--threads` option (and the `grep.threads` configuration) will be ignored wh
344 `--open-files-in-pager` is used, forcing a single-threaded execution.
345
346 When grepping the object store (with `--cached` or giving tree objects), running
339 -with multiple threads might perform slower than single threaded if `--textconv`
340 -is given and there are too many text conversions. So if you experience low
341 -performance in this case, it might be desirable to use `--threads=1`.
347 +with multiple threads might perform slower than single-threaded if `--textconv`
348 +is given and there are too many text conversions. Thus, if low performance is
349 +experienced in this case, it might be desirable to use `--threads=1`.
350
351 CONFIGURATION
352 -------------