git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Brandon Williams <bmwill@google.com>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Stefan Beller <sbeller@google.com>,
	Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH v3 3/5] grep: fix bug when recursing with relative pathspec
Date: Wed, 22 Mar 2017 14:46:54 -0700	[thread overview]
Message-ID: <20170322214654.GC11254@google.com> (raw)
In-Reply-To: <CACsJy8Cu8cgtJzDDM09GoJr5Ny+G+nP17GjZjXng6ZPQv9eXXg@mail.gmail.com>

On 03/21, Duy Nguyen wrote:
> On Sat, Mar 18, 2017 at 12:22 AM, Brandon Williams <bmwill@google.com> wrote:
> > With these two pieces of information a child process can correctly
> > interpret the pathspecs provided by the user as well as being able to
> > properly format its output relative to the directory the user invoked
> > the original command from.
> 
> This part can stand alone as a separate patch right? It would help
> focus on the pathspec thingy first.

I guess it could probably be factored out, though it is necessary for it
to work.  The issue I was running into was that when no pathspecs were
given it would create a 'prefix' pathspec.  So if we were in directory
'dir/' the pathspec that would get created would be:

ps.match = "dir/"
ps.original = "dir/"

Since it also set the original field it messed up when the child tried
to interpret the pathspecs again.  I solved this by just passing the raw
pathspec through to the child.

> 
> > @@ -399,13 +405,12 @@ static void run_pager(struct grep_opt *opt, const char *prefix)
> >  }
> >
> >  static void compile_submodule_options(const struct grep_opt *opt,
> > -                                     const struct pathspec *pathspec,
> > +                                     const char **argv,
> >                                       int cached, int untracked,
> >                                       int opt_exclude, int use_index,
> >                                       int pattern_type_arg)
> >  {
> >         struct grep_pat *pattern;
> > -       int i;
> >
> >         if (recurse_submodules)
> >                 argv_array_push(&submodule_options, "--recurse-submodules");
> 
> Side note. It would be awesome if you could make parse_options() (or a
> new function) do the reverse process: given a 'struct option' with
> valid data, spit out argv_array. Less worrying about git-grep having
> new option but not passed to subgrep by accident. You can have a new
> flag to tell it to ignore certain options if you don't want to pass
> all.

I thought about this for a second but didn't pursue it very far.  Mostly
because of how you would handle options with callback routines.  Maybe
if you want the option to be reversible you need to have an additional
callback routine to do the conversion?  I agree that having this sort of
functionality would be nice as it does save you from forgetting about
passing on options to a child process.

-- 
Brandon Williams

  parent reply	other threads:[~2017-03-22 21:47 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-24 23:50 [PATCH 0/5] recursing submodules with relative pathspec (grep and ls-files) Brandon Williams
2017-02-24 23:50 ` [PATCH 1/5] grep: illustrate bug when recursing with relative pathspec Brandon Williams
2017-02-26  9:53   ` Duy Nguyen
2017-02-27 18:14     ` Brandon Williams
2017-02-24 23:50 ` [PATCH 2/5] pathspec: add PATHSPEC_FROMROOT flag Brandon Williams
2017-02-25  0:31   ` Stefan Beller
2017-02-24 23:50 ` [PATCH 3/5] grep: fix bug when recuring with relative pathspec Brandon Williams
2017-02-28 21:04   ` Junio C Hamano
2017-03-02 18:00     ` Brandon Williams
2017-02-24 23:50 ` [PATCH 4/5] ls-files: illustrate bug when recursing " Brandon Williams
2017-02-24 23:51 ` [PATCH 5/5] ls-files: fix bug when recuring " Brandon Williams
2017-02-28 21:07   ` Junio C Hamano
2017-03-02 18:01     ` Brandon Williams
2017-02-27 17:52 ` [PATCH 0/5] recursing submodules with relative pathspec (grep and ls-files) Brandon Williams
2017-03-06 23:07 ` [RFC PATCH] grep: fix bug when recursing with relative pathspec Brandon Williams
2017-03-14 22:10 ` [PATCH v2 0/4] recursing submodules with relative pathspec (grep and ls-files) Brandon Williams
2017-03-14 22:10   ` [PATCH v2 1/4] grep: fix help text typo Brandon Williams
2017-03-14 22:49     ` Stefan Beller
2017-03-15  0:20       ` Brandon Williams
2017-03-14 22:10   ` [PATCH v2 2/4] setup: allow for prefix to be passed to git commands Brandon Williams
2017-03-14 22:28     ` Johannes Schindelin
2017-03-14 22:35       ` Brandon Williams
2017-03-14 22:10   ` [PATCH v2 3/4] grep: fix bug when recursing with relative pathspec Brandon Williams
2017-03-14 23:03     ` Stefan Beller
2017-03-14 22:11   ` [PATCH v2 4/4] ls-files: " Brandon Williams
2017-03-14 23:06     ` Stefan Beller
2017-03-15 17:02       ` Brandon Williams
2017-03-17 17:22   ` [PATCH v3 0/5] recursing submodules with relative pathspec (grep and ls-files) Brandon Williams
2017-03-17 17:22     ` [PATCH v3 1/5] grep: fix help text typo Brandon Williams
2017-03-17 17:22     ` [PATCH v3 2/5] setup: allow for prefix to be passed to git commands Brandon Williams
2017-03-17 19:07       ` Stefan Beller
2017-03-17 19:08         ` Brandon Williams
2017-03-17 19:10           ` Stefan Beller
2017-03-17 19:17             ` Brandon Williams
2017-03-17 19:17         ` Junio C Hamano
2017-03-17 19:21           ` Brandon Williams
2017-03-17 20:30             ` Junio C Hamano
2017-03-17 21:00               ` Brandon Williams
2017-03-17 21:25                 ` Junio C Hamano
2017-03-20 22:34                   ` Brandon Williams
2017-03-21 16:56                     ` Junio C Hamano
2017-03-28 23:58                     ` Stefan Beller
2017-03-17 17:22     ` [PATCH v3 3/5] grep: fix bug when recursing with relative pathspec Brandon Williams
2017-03-21 11:47       ` Duy Nguyen
2017-03-21 17:56         ` Junio C Hamano
2017-03-22 21:46         ` Brandon Williams [this message]
2017-03-17 17:22     ` [PATCH v3 4/5] ls-files: fix typo in variable name Brandon Williams
2017-03-17 17:22     ` [PATCH v3 5/5] ls-files: fix bug when recursing with relative pathspec Brandon Williams

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=20170322214654.GC11254@google.com \
    --to=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=sbeller@google.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).