git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Denton Liu <liu.denton@gmail.com>
Cc: Emily Shaffer <emilyshaffer@google.com>, git@vger.kernel.org
Subject: Re: [PATCH] grep: provide pathspecs/patterns via file or stdin
Date: Fri, 22 Nov 2019 11:34:17 +0900	[thread overview]
Message-ID: <xmqqwobs7i6u.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20191122021419.GA52557@generichostname> (Denton Liu's message of "Thu, 21 Nov 2019 18:14:20 -0800")

Denton Liu <liu.denton@gmail.com> writes:

> The reason I ask is because (correct me if I'm wrong) a lot of other git
> commands (like add, reset and checkout) don't seem to accept pathspecs
> via stdin and could suffer the same problem. xargs seems like a more
> general way of solving the problem of long command lines.

You contributors who are potentially throwing your own topics into
the cauldron, please be paying a bit more attention to other topics
already cooking in the pot.  I think am/pathspec-from-file wants to
go in the general direction.

There are things "xargs" is sufficient, and there are things that
absolutely requires a single invocation of "git".  "grep" is a bit
of both.

    $ git grep -e "$pattern" -- A B C

(where A, B and C are hundreds) can be split into three independent
invocations of "git grep" via "xargs", essentially running

    $ git grep -e "$pattern" -- A
    $ git grep -e "$pattern" -- B
    $ git grep -e "$pattern" -- C

independently.

But

    $ git grep -e P1 -e P2 -e P3 -- A

(where each of "-e Pn" in reality may be "-e Pn1 -e Pn2 -e Pn3..."
that has hundreds of patterns) cannot be split into separate
invocations and keep the same meaning.

    $ git grep -e P1 -- A
    $ git grep -e P2 -- A
    $ git grep -e P3 -- A

may show the same lines, but (1) lines with both P1 and P2 would be
shown duplicated, and (2) the order of the output would be different
from a single invocation looking for all patterns at once.

Needless to say, the ability to combine patterns with --all-match,
--and, etc., and negate them would mean the list of patterns must be
split (even when it makes sense to do so) at the right places.

    $ git grep -e P1 --and -e P2

cannot be split into two or more invocations, for example.







  reply	other threads:[~2019-11-22  2:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22  1:16 [PATCH] grep: provide pathspecs/patterns via file or stdin Emily Shaffer
2019-11-22  2:14 ` Denton Liu
2019-11-22  2:34   ` Junio C Hamano [this message]
2019-11-22  3:56     ` Junio C Hamano
2019-11-22 18:52     ` Denton Liu
2019-11-22 22:02     ` Emily Shaffer
2019-11-22 22:06       ` Emily Shaffer
2019-11-23  0:28       ` Junio C Hamano
2019-11-22  2:24 ` Junio C Hamano
2019-12-04 20:39 ` [PATCH v2] grep: support the --pathspec-from-file option Emily Shaffer
2019-12-04 21:05   ` Denton Liu
2019-12-04 21:24     ` Junio C Hamano
2019-12-04 22:24   ` Junio C Hamano
2019-12-13  3:07     ` Emily Shaffer
2019-12-05 11:58   ` Alexandr Miloslavskiy
2019-12-13  4:00     ` Emily Shaffer
2019-12-06 11:22   ` Johannes Schindelin
2019-12-06 11:34   ` SZEDER Gábor
2019-12-13  4:12   ` [PATCH v3] " Emily Shaffer
2019-12-13 13:04     ` Alexandr Miloslavskiy
2019-12-13 18:26     ` Junio C Hamano
2019-12-13 20:13       ` Alexandr Miloslavskiy
2019-12-17  0:33         ` Emily Shaffer

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqwobs7i6u.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=liu.denton@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).