git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/5] grep docs: describe --no-index further

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 19, 2024, 00:55 UTC
Message-ID
<xmqqwmpzrqfv.fsf@gitster.g>
In-Reply-To
<3e6136028ca3327b027d57c46fb8155ef3c0d6c5.1710781235.git.dsimic@manjaro.org>
Dragan Simic <dsimic@manjaro.org> writes:
Show 11 quoted lines
> ---no-index::
> -	Search files in the current directory that is not managed by Git.
> -
>  --untracked::
>  	In addition to searching in the tracked files in the working
>  	tree, search also in untracked files.
>  
> +--no-index::
> +	Search files in the current directory that is not managed by Git.
> +	This option cannot be used together with `--cached` or `--untracked`.
> +	See also `grep.fallbackToNoIndex` in CONFIGURATION below.

Hmph, this is not the fault of this patch, but the description is iffy. You can run "git grep --no-index" inside a directory that is managed by Git, and it behaves as if you gave --untracked, if I am not mistaken.

What "--no-index" does is to pretend that there is no system called Git and work as if it were a strange implementation of "grep -r". The reader should be taught to understand the mode as such, because that understanding will apply whether the current directory happens to be part of a working tree managed by git, or not under control by git repository anywhere.

There is no tracked or untracked or managed or anything like that, as we are pretending that there is no git, so it falls naturally that --cached or --untracked would not work.

And from that point of view, swapping the order of "--no-index" and "--untracked" in this patch does make sense. All other options that specify which haystack to find the needle in are all about git; "--no-index" truly is an oddball that pretends that we live in a world without git, and as an oddball, we should move the description out from where it does not belong. It might also make sense to rethink where `--recurse-submodules` sits in the list of options while at it, as it also is an option that affects which haystack the search for the needle is carried out.

>  --no-exclude-standard::
>  	Also search in ignored files by not honoring the `.gitignore`
>  	mechanism. Only useful with `--untracked`.
Previous: Dragan SimicNext: Dragan Simic
Message 3 of 22 in “New config option for git-grep to include untracked files”
  1. 0/5 New config option for git-grep to include untracked filesDragan Simic, Mar 18, 2024
  2. 3/5 grep docs: describe --no-index furtherDragan Simic, Mar 18, 2024
  3. Junio C HamanoMar 19, 2024
  4. Dragan SimicMar 19, 2024
  5. 4/5 grep: introduce new config option to include untracked filesDragan Simic, Mar 18, 2024
  6. Junio C HamanoMar 19, 2024
  7. Dragan SimicMar 19, 2024
  8. Junio C HamanoMar 19, 2024
  9. Dragan SimicMar 19, 2024
  10. 2/5 grep docs: describe --recurse-submodules further and improve formatting a bitDragan Simic, Mar 18, 2024
  11. Eric SunshineMar 18, 2024
  12. Dragan SimicMar 18, 2024
  13. 1/5 grep: perform some minor code and comment cleanupsDragan Simic, Mar 18, 2024
  14. Eric SunshineMar 18, 2024
  15. Dragan SimicMar 18, 2024
  16. Junio C HamanoMar 19, 2024
  17. Dragan SimicMar 19, 2024
  18. 5/5 grep docs: describe new config option to include untracked filesDragan Simic, Mar 18, 2024
  19. Junio C HamanoMar 19, 2024
  20. Dragan SimicMar 19, 2024
  21. Junio C HamanoMar 19, 2024
  22. Dragan SimicMar 19, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.