git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: Matheus Tavares <matheus.bernardino@usp.br>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] grep: error out if --untracked is used with --cached
Date: Tue, 9 Feb 2021 02:07:12 -0800	[thread overview]
Message-ID: <CABPp-BFx6HmoVBsS2Aeb+GgZTC8axwGcuWrkpaCFxM-j2SOMww@mail.gmail.com> (raw)
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:
>
> 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>

      parent reply	other threads:[~2021-02-09 10:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 19:43 [PATCH] grep: error out if --untracked is used with --cached Matheus Tavares
2021-02-08 21:48 ` Taylor Blau
2021-02-08 23:21   ` Matheus Tavares
2021-02-09 10:06     ` Elijah Newren
2021-02-09 20:38       ` Junio C Hamano
2021-02-10  2:43         ` Taylor Blau
2021-02-09 10:07 ` Elijah Newren [this message]

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=CABPp-BFx6HmoVBsS2Aeb+GgZTC8axwGcuWrkpaCFxM-j2SOMww@mail.gmail.com \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=matheus.bernardino@usp.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).