Re: [PATCH] grep: provide pathspecs/patterns via file or stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Denton Liu <liu.denton@xxxxxxxxx> 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.









[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux