From: Denton Liu <liu.denton@gmail.com>
To: Emily Shaffer <emilyshaffer@google.com>
Cc: git@vger.kernel.org,
Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2] grep: support the --pathspec-from-file option
Date: Wed, 4 Dec 2019 13:05:14 -0800 [thread overview]
Message-ID: <20191204210514.GA89300@generichostname> (raw)
In-Reply-To: <20191204203911.237056-1-emilyshaffer@google.com>
Hi Emily,
On Wed, Dec 04, 2019 at 12:39:11PM -0800, Emily Shaffer wrote:
> @@ -289,6 +293,20 @@ In future versions we may learn to support patterns containing \0 for
> more search backends, until then we'll die when the pattern type in
> question doesn't support them.
>
> +--pathspec-from-file <file>::
> + Read pathspec from <file> instead of the command line. If `<file>` is
> + exactly `-` then standard input is used; standard input cannot be used
> + for both --patterns-from-file and --pathspec-from-file. Pathspec elements
> + are separated by LF or CR/LF. Pathspec elements can be quoted as
> + explained for the configuration variable `core.quotePath` (see
> + linkgit:git-config[1]). See also `--pathspec-file-nul` and global
> + `--literal-pathspecs`.
> +
> +--pathspec-file-nul::
> + Only meaningful with `--pathspec-from-file`. Pathspec elements are
> + separated with NUL character and all other characters are taken
> + literally (including newlines and quotes).
Does it make sense to have a corresponding --patterns-file-nul option?
As in, is it possible for patterns to contain inline newlines? If it's
not possible, then that option probably isn't necessary.
> +
> -e::
> The next parameter is the pattern. This option has to be
> used for patterns starting with `-` and should be used in
> @@ -1125,6 +1129,44 @@ test_expect_success 'grep --no-index descends into repos, but not .git' '
> )
> '
>
> +test_expect_success 'setup pathspecs-file tests' '
> +cat >excluded-file <<EOF &&
> +bar
> +EOF
> +cat >pathspec-file <<EOF &&
> +foo
> +bar
> +baz
> +EOF
> +cat >unrelated-file <<EOF &&
> +xyz
> +EOF
> +git add excluded-file pathspec-file unrelated-file
> +'
Could you please change these here-docs to be <<-\EOF and then indent
the test case?
> +
> +cat >pathspecs <<EOF
> +pathspec-file
> +unrelated-file
> +EOF
> +
> +cat >expected <<EOF
> +pathspec-file:bar
> +EOF
In an earlier email, I was wondering aloud why these two blocks were
outside of the test case above. I think the answer to that is that
you're following the existing style of the test case.
In that case, could I pester you to do some test clean up while you're
at it? I think it'd be nice to move the cats into their respective test
cases (with <<-\EOF) and also rename the files from 'expected' to
'expect'. But otherwise, I think it's fine as is as well.
Thanks,
Denton
> +
> +test_expect_success 'grep --pathspec-from-file with file' '
> + git grep --pathspec-from-file pathspecs "bar" >actual &&
> + test_cmp expected actual
> +'
> +
> +test_expect_success 'grep --pathspec-file with stdin' '
> + git grep --pathspec-from-file - "bar" <pathspecs >actual &&
> + test_cmp expected actual
> +'
> +
> +test_expect_success 'grep with two stdin inputs fails' '
> + test_must_fail git grep --pathspec-from-file - --patterns-from-file - <pathspecs
> +'
> +
> test_expect_success 'setup double-dash tests' '
> cat >double-dash <<EOF &&
> --
> --
> 2.24.0.393.g34dc348eaf-goog
>
next prev parent reply other threads:[~2019-12-04 21:05 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
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 [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191204210514.GA89300@generichostname \
--to=liu.denton@gmail.com \
--cc=alexandr.miloslavskiy@syntevo.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.