From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Emily Shaffer <emilyshaffer@google.com>
Cc: git@vger.kernel.org,
Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>,
Denton Liu <liu.denton@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v2] grep: support the --pathspec-from-file option
Date: Fri, 6 Dec 2019 12:34:01 +0100 [thread overview]
Message-ID: <20191206113401.GA2746@szeder.dev> (raw)
In-Reply-To: <20191204203911.237056-1-emilyshaffer@google.com>
On Wed, Dec 04, 2019 at 12:39:11PM -0800, Emily Shaffer wrote:
> Teach 'git grep' to use OPT_PATHSPEC_FROM_FILE and update the
> documentation accordingly.
> diff --git a/builtin/grep.c b/builtin/grep.c
> index 50ce8d9461..54ba991c42 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -809,6 +813,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
> int use_index = 1;
> int pattern_type_arg = GREP_PATTERN_TYPE_UNSPECIFIED;
> int allow_revs;
> + char *pathspec_from_file;
> + int pathspec_file_nul;
Uninitialized variables ...
>
> struct option options[] = {
> OPT_BOOL(0, "cached", &cached,
> @@ -896,8 +902,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
> OPT_BOOL('W', "function-context", &opt.funcbody,
> N_("show the surrounding function")),
> OPT_GROUP(""),
> - OPT_CALLBACK('f', NULL, &opt, N_("file"),
> + OPT_CALLBACK('f', "patterns-from-file", &opt, N_("file"),
> N_("read patterns from file"), file_callback),
> + OPT_PATHSPEC_FROM_FILE(&pathspec_from_file),
> + OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul),
> { OPTION_CALLBACK, 'e', NULL, &opt, N_("pattern"),
> N_("match <pattern>"), PARSE_OPT_NONEG, pattern_callback },
> { OPTION_CALLBACK, 0, "and", &opt, NULL,
> @@ -1062,6 +1070,23 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
> pathspec.recursive = 1;
> pathspec.recurse_submodules = !!recurse_submodules;
>
> + if (pathspec_from_file) {
... one of which is checked here ...
> + if (pathspec.nr)
> + die(_("--pathspec-from-file is incompatible with pathspec arguments"));
... causing a lot of tests to fail in our OSX CI builds (but,
strangely, in none of the Linux builds), either with the above error
message, e.g.:
expecting success of 4014.150 'format-patch --pretty=mboxrd':
[...]
++git format-patch --pretty=mboxrd --stdout -1 01b96447182ff76f30268fb82d3f9e9e09b14e6c~1..01b96447182ff76f30268fb82d3f9e9e09b14e6c
++git grep -h --no-index -A11 '^>From could trip up a loose mbox parser' patch
fatal: --pathspec-from-file is incompatible with pathspec arguments
error: last command exited with $?=128
or with:
expecting success of 7814.2 'grep correctly finds patterns in a submodule':
[...]
++git grep -e '(3|4)' --recurse-submodules
fatal: could not open '����?' for reading: No such file or directory
error: last command exited with $?=128
> + pathspec_from_stdin = !strcmp(pathspec_from_file, "-");
> +
> + if (patterns_from_stdin && pathspec_from_stdin)
> + die(_("cannot specify both patterns and pathspec via stdin"));
> +
> + parse_pathspec_file(&pathspec, 0, PATHSPEC_PREFER_CWD |
> + (opt.max_depth != -1 ? PATHSPEC_MAXDEPTH_VALID : 0),
> + prefix, pathspec_from_file,
> + pathspec_file_nul);
The other uninitialized variable is passed as parameter above and
checked below, but I haven't seen any test failures caused by it.
> + } else if (pathspec_file_nul) {
> + die(_("--pathspec-file-nul requires --pathspec-from-file"));
> + }
> +
> if (list.nr || cached || show_in_pager) {
> if (num_threads > 1)
> warning(_("invalid option combination, ignoring --threads"));
next prev parent reply other threads:[~2019-12-06 11: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
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 [this message]
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=20191206113401.GA2746@szeder.dev \
--to=szeder.dev@gmail.com \
--cc=alexandr.miloslavskiy@syntevo.com \
--cc=emilyshaffer@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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.
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).