public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Dragan Simic <dsimic@manjaro•org>
Cc: git@vger•kernel.org
Subject: Re: [PATCH 3/5] grep docs: describe --no-index further
Date: Mon, 18 Mar 2024 17:55:00 -0700	[thread overview]
Message-ID: <xmqqwmpzrqfv.fsf@gitster.g> (raw)
In-Reply-To: <3e6136028ca3327b027d57c46fb8155ef3c0d6c5.1710781235.git.dsimic@manjaro.org> (Dragan Simic's message of "Mon, 18 Mar 2024 18:03:23 +0100")

Dragan Simic <dsimic@manjaro•org> writes:

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

  reply	other threads:[~2024-03-19  0:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 17:03 [PATCH 0/5] New config option for git-grep to include untracked files Dragan Simic
2024-03-18 17:03 ` [PATCH 1/5] grep: perform some minor code and comment cleanups Dragan Simic
2024-03-18 19:59   ` Eric Sunshine
2024-03-18 22:03     ` Dragan Simic
2024-03-19  0:32     ` Junio C Hamano
2024-03-19  5:33       ` Dragan Simic
2024-03-18 17:03 ` [PATCH 2/5] grep docs: describe --recurse-submodules further and improve formatting a bit Dragan Simic
2024-03-18 20:02   ` Eric Sunshine
2024-03-18 22:14     ` Dragan Simic
2024-03-18 17:03 ` [PATCH 3/5] grep docs: describe --no-index further Dragan Simic
2024-03-19  0:55   ` Junio C Hamano [this message]
2024-03-19  5:37     ` Dragan Simic
2024-03-18 17:03 ` [PATCH 4/5] grep: introduce new config option to include untracked files Dragan Simic
2024-03-19  0:58   ` Junio C Hamano
2024-03-19  5:47     ` Dragan Simic
2024-03-19 14:32       ` Junio C Hamano
2024-03-19 14:52         ` Dragan Simic
2024-03-18 17:03 ` [PATCH 5/5] grep docs: describe " Dragan Simic
2024-03-19  0:21 ` [PATCH 0/5] New config option for git-grep " Junio C Hamano
2024-03-19  5:09   ` Dragan Simic
2024-03-19 17:43     ` Junio C Hamano
2024-03-19 17:48       ` Dragan Simic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqwmpzrqfv.fsf@gitster.g \
    --to=gitster@pobox$(echo .)com \
    --cc=dsimic@manjaro$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox