git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Kristoffer Haugsbakk <code@khaugsbakk.name>,
	 git@vger.kernel.org, ks1322@gmail.com
Subject: Re: [PATCH] grep: die gracefully when outside repository
Date: Sun, 15 Oct 2023 10:57:36 -0700	[thread overview]
Message-ID: <xmqq7cnnpy3z.fsf@gitster.g> (raw)
In-Reply-To: <20231015032636.GC554702@coredump.intra.peff.net> (Jeff King's message of "Sat, 14 Oct 2023 23:26:36 -0400")

Jeff King <peff@peff.net> writes:

> Is it even reasonable for "grep --no-index" to care about leaving the
> tree in the first place? That is, is there a reason we should not allow:
>
>   git grep --no-index foo ../bar

A huge difference between the bare "grep" and "git grep" is that we
know the scope of the project tree, so it goes recursive by default.
Should the above command line recursively go below ../bar?  Would we
allow "/" to be given?

I actually do not think these "we are allowing Git tools to be used
on random garbage" is a good idea to begin with X-<.  If we invented
something nice for our variant in "git grep" and wish we can use it
outside the repository, contributing the feature to implementations
of "grep" would have been the right way to move forward, instead of
contaminating the codebase with things that are not related to Git.
Whoever did 59332d13 (Resurrect "git grep --no-index", 2010-02-06)
should be punished X-<.

Anyway.

2e48fcdb (grep docs: document --no-index option, 2010-02-25) seems
to have wanted to explicitly limit the search within the "current
directory", and I am fine to keep the search space limited by the
cwd.  On the other hand, of course, the users can shoot themselves
in the foot with "grep -r foo /", so letting them use "git grep" the
same way is perhaps OK.  Especially if it simplifies the code if we
lift the limitation, that is a very tempting thing to do.

> If we want to avoid leaving the current directory, then I think we need
> to be checking much sooner (but again, I would argue that it is not
> worth caring about in no-index mode).

  parent reply	other threads:[~2023-10-15 17:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-14 15:42 Bug: git grep --no-index 123 /dev/stdin crashes with SIGABRT ks1322 ks1322
2023-10-14 18:12 ` Kristoffer Haugsbakk
2023-10-14 19:37   ` Kristoffer Haugsbakk
2023-10-14 21:02     ` [PATCH] grep: die gracefully when outside repository Kristoffer Haugsbakk
2023-10-15  3:26       ` Jeff King
2023-10-15  8:00         ` Kristoffer Haugsbakk
2023-10-15 17:57         ` Junio C Hamano [this message]
2023-10-17 16:42       ` Junio C Hamano
2023-10-17 19:51         ` Kristoffer Haugsbakk
2023-10-17 20:25           ` Junio C Hamano
2023-10-17 20:39       ` Junio C Hamano
2023-10-20 16:40       ` [PATCH v2] " Kristoffer Haugsbakk
2023-10-20 17:05         ` Eric Sunshine
2023-10-20 18:06           ` Junio C Hamano
2023-10-20 18:04       ` [PATCH v3] " Kristoffer Haugsbakk

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=xmqq7cnnpy3z.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=code@khaugsbakk.name \
    --cc=git@vger.kernel.org \
    --cc=ks1322@gmail.com \
    --cc=peff@peff.net \
    /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).