git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brandon Williams <bmwill@google.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, pclouds@gmail.com
Subject: Re: [PATCH] pathspec: only match across submodule boundaries when requested
Date: Mon, 4 Dec 2017 16:09:01 -0800	[thread overview]
Message-ID: <20171205000901.GB52452@google.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1.1711292221060.6482@virtualbox>

On 11/29, Johannes Schindelin wrote:
> Hi Brandon,
> 
> On Tue, 28 Nov 2017, Brandon Williams wrote:
> 
> > Commit 74ed43711fd (grep: enable recurse-submodules to work on <tree>
> > objects, 2016-12-16) taught 'tree_entry_interesting()' to be able to
> > match across submodule boundaries in the presence of wildcards.  This is
> > done by performing literal matching up to the first wildcard and then
> > punting to the submodule itself to perform more accurate pattern
> > matching.  Instead of introducing a new flag to request this behavior,
> > commit 74ed43711fd overloaded the already existing 'recursive' flag in
> > 'struct pathspec' to request this behavior.
> > 
> > This leads to a bug where whenever any other caller has the 'recursive'
> > flag set as well as a pathspec with wildcards that all submodules will
> > be indicated as matches.  One simple example of this is:
> > 
> > 	git init repo
> > 	cd repo
> > 
> > 	git init submodule
> > 	git -C submodule commit -m initial --allow-empty
> > 
> > 	touch "[bracket]"
> > 	git add "[bracket]"
> > 	git commit -m bracket
> > 	git add submodule
> > 	git commit -m submodule
> > 
> > 	git rev-list HEAD -- "[bracket]"
> > 
> > Fix this by introducing the new flag 'recurse_submodules' in 'struct
> > pathspec' and using this flag to determine if matches should be allowed
> > to cross submodule boundaries.
> > 
> > Signed-off-by: Brandon Williams <bmwill@google.com>
> 
> Could you also add something like
> 
> 	This fixes https://github.com/git-for-windows/git/issues/1371
> 
> at the end of the commit message, to keep a reference to the original bug
> report?

Yep! I can do that.

> 
> >  4 files changed, 22 insertions(+), 2 deletions(-)
> 
> Phew. That was much smaller than I expected.
> 
> > +test_expect_success 'tree_entry_interesting does not match past submodule boundaries' '
> > +	test_when_finished "rm -rf repo submodule" &&
> > +	git init submodule &&
> > +	test_commit -C submodule initial &&
> > +	git init repo &&
> > +	>"repo/[bracket]" &&
> > +	git -C repo add "[bracket]" &&
> > +	git -C repo commit -m bracket &&
> > +	git -C repo rev-list HEAD -- "[bracket]" >expect &&
> > +
> > +	git -C repo submodule add ../submodule &&
> > +	git -C repo commit -m submodule &&
> > +
> > +	git -C repo rev-list HEAD -- "[bracket]" >actual &&
> > +	test_cmp expect actual
> > +'
> 
> Nicely prepared for a new hash function, too (no explicit SHA-1).
> 
> I wonder, however, why we can't `git checkout -b bracket` and
> `test_when_finished "git checkout master"` and void those many `-C repo`
> options. But then, it is actually one of the shorter test cases, and
> pretty easy to understand.
> 
> However, I would still like to see `test_tick`s before those `git commit`
> calls, to make the commit names reproducible.

In v2 I added the calls to test_tick.  I've never used the function
myself so hopefully I used it correctly! :)

> 
> Thanks,
> Dscho

-- 
Brandon Williams

  reply	other threads:[~2017-12-05  0:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-26  2:15 Bug in pathspec handling (in conjunction with submodules) Johannes Schindelin
2017-11-28 23:06 ` Brandon Williams
2017-11-28 23:22 ` [PATCH] pathspec: only match across submodule boundaries when requested Brandon Williams
2017-11-29 21:29   ` Johannes Schindelin
2017-12-05  0:09     ` Brandon Williams [this message]
2017-12-05  0:07   ` [PATCH v2] " Brandon Williams
2017-12-05 19:19     ` Junio C Hamano
2017-12-06 21:20     ` Johannes Schindelin

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=20171205000901.GB52452@google.com \
    --to=bmwill@google.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=pclouds@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).