Skip to content

Commit 6e9ef29

Browse files
Dragan Simicgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a9357a commit 6e9ef29

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

Documentation/git-grep.txt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SYNOPSIS
2828
[-f <file>] [-e] <pattern>
2929
[--and|--or|--not|(|)|-e <pattern>...]
3030
[--recurse-submodules] [--parent-basename <basename>]
31-
[ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | <tree>...]
31+
[ [--[no-]exclude-standard] [--cached | --untracked | --no-index] | <tree>...]
3232
[--] [<pathspec>...]
3333

3434
DESCRIPTION
@@ -45,13 +45,21 @@ OPTIONS
4545
Instead of searching tracked files in the working tree, search
4646
blobs registered in the index file.
4747

48-
--no-index::
49-
Search files in the current directory that is not managed by Git.
50-
5148
--untracked::
5249
In addition to searching in the tracked files in the working
5350
tree, search also in untracked files.
5451

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+
5563
--no-exclude-standard::
5664
Also search in ignored files by not honoring the `.gitignore`
5765
mechanism. Only useful with `--untracked`.
@@ -248,8 +256,8 @@ providing this option will cause it to die.
248256
a non-zero status.
249257

250258
--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.
253261

254262
-f <file>::
255263
Read patterns from <file>, one per line.
@@ -336,9 +344,9 @@ The `--threads` option (and the `grep.threads` configuration) will be ignored wh
336344
`--open-files-in-pager` is used, forcing a single-threaded execution.
337345

338346
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`.
342350

343351
CONFIGURATION
344352
-------------

0 commit comments

Comments
 (0)