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

Re: [PATCH] grep: error out if --untracked is used with --cached

From
Elijah Newren <newren@gmail.com>
Date
Feb 9, 2021, 10:07 UTC
Message-ID
<CABPp-BFx6HmoVBsS2Aeb+GgZTC8axwGcuWrkpaCFxM-j2SOMww@mail.gmail.com>
In-Reply-To
<5bd9dce8f611c5fe380c9f58dbdfa2dc6d2fd51f.1612813249.git.matheus.bernardino@usp.br>

On Mon, Feb 8, 2021 at 11:47 AM Matheus Tavares <matheus.bernardino@usp.br> wrote:

Show 26 quoted lines
>
> The options --untracked and --cached are not compatible, but if they are
> used together, grep just silently ignores --cached and searches the
> working tree. Error out, instead, to avoid any potential confusion.
>
> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
> ---
>  builtin/grep.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/builtin/grep.c b/builtin/grep.c
> index ca259af441..392acf8cab 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -1157,6 +1157,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
>         if (!use_index && (untracked || cached))
>                 die(_("--cached or --untracked cannot be used with --no-index"));
>
> +       if (untracked && cached)
> +               die(_("--untracked cannot be used with --cached"));
> +
>         if (!use_index || untracked) {
>                 int use_exclude = (opt_exclude < 0) ? use_index : !!opt_exclude;
>                 hit = grep_directory(&opt, &pathspec, use_exclude, use_index);
> --
> 2.29.2
Reviewed-by: Elijah Newren <newren@gmail.com>
Previous: Taylor Blau
Message 7 of 7 in “grep: error out if --untracked is used with --cached”
  1. grep: error out if --untracked is used with --cachedMatheus Tavares, Feb 8, 2021
  2. Taylor BlauFeb 8, 2021
  3. Matheus TavaresFeb 8, 2021
  4. Elijah NewrenFeb 9, 2021
  5. Junio C HamanoFeb 9, 2021
  6. Taylor BlauFeb 10, 2021
  7. Elijah NewrenFeb 9, 2021

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.