From: Junio C Hamano <gitster@pobox.com>
To: Albert Yale <surfingalbert@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/RFC v2] grep: Add the option '--exclude'
Date: Sun, 29 Jan 2012 15:02:57 -0800 [thread overview]
Message-ID: <7vvcnudsda.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1327876934-61526-1-git-send-email-surfingalbert@gmail.com> (Albert Yale's message of "Sun, 29 Jan 2012 17:42:14 -0500")
Albert Yale <surfingalbert@gmail.com> writes:
> Feedback would again be appreciated,
Hmm.
> [-f <file>] [-e] <pattern>
> + [-x<pattern>|--exclude<pattern>]
Compare the above two lines and notice some funny in the added one?
> @@ -124,6 +125,12 @@ OPTIONS
> Use fixed strings for patterns (don't interpret pattern
> as a regex).
>
> +-x<pattern>::
> +--exclude<pattern>::
> + In addition to those found in .gitignore (per directory) and
> + $GIT_DIR/info/exclude, also consider these patterns to be in the
> + set of the ignore rules in effect.
> +
Likewise.
> diff --git a/builtin/grep.c b/builtin/grep.c
> index 9ce064a..9772fa4 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -530,6 +530,10 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
> continue;
> if (!match_pathspec_depth(pathspec, ce->name, ce_namelen(ce), 0, NULL))
> continue;
> + if (pathspec->exclude &&
> + pathspec->exclude->nr &&
> + match_pathspec_depth(pathspec->exclude, ce->name, ce_namelen(ce), 0, NULL))
> + continue;
Why isn't this just
if (!match_pathspec_depth(pathspec, ce->name, ce_namelen(ce), 0, NULL))
that is, *no change whatsoever* on the existing codepaths that call
match_pathspec_depth()? Can't the "even if one of the positive pathspec
matched, if one of the excluded one matches, declare that the path does
*not* match" logic live in match_pathspec_depth() itself?
Exactly the same comment applies to all the other additions that calls
match_pathspec_depth() with pathspec->exclude as its first parameter in
this patch.
> @@ -1053,6 +1084,12 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
> pathspec.max_depth = opt.max_depth;
> pathspec.recursive = 1;
>
> + if( exclude_list.nr ) {
> + create_pathspec_from_string_list(&pathspec.exclude, &exclude_list);
> + pathspec.exclude->max_depth = opt.max_depth;
> + pathspec.exclude->recursive = 1;
> + }
> +
Style. Notice where SPs should be near parentheses on "if" statement in
our codebase.
next prev parent reply other threads:[~2012-01-29 23:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-29 22:42 [PATCH/RFC v2] grep: Add the option '--exclude' Albert Yale
2012-01-29 23:02 ` Junio C Hamano [this message]
2012-01-30 0:01 ` Albert Yale
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=7vvcnudsda.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=surfingalbert@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).