Re: git-grep in sparse checkout
- From
Bert Wesarg <bert.wesarg@googlemail.com>
- Date
- Oct 1, 2019, 13:30 UTC
- Message-ID
- <CAKPyHN3G-j6p8YZmk+07Sb3tL9vua_R-hJ=W81O7vCYr07AkxA@mail.gmail.com>
- In-Reply-To
- <CAHd-oW7e5qCuxZLBeVDq+Th3E+E4+P8=WzJfK8WcG2yz=n_nag@mail.gmail.com>
Hi,
On Tue, Oct 1, 2019 at 3:06 PM Matheus Tavares Bernardino <matheus.bernardino@usp.br> wrote:
Show 10 quoted lines
> > Hi, > > During Git Summit it was mentioned that git-grep searches outside > sparsity pattern which is not aligned with user expectation. I took a > quick look at it and it seems the reason is > builtin/grep.c:grep_cache() (which also greps worktree) will grep the > object store when a given index entry has the CE_SKIP_WORKTREE bit > turned on. >
I also had once this problem and found that out and wrote a patch. I was just about to send this patch out.
Btw, ls-files should also learn to skip worktree files.
Stay tuned.
Bert
Show 14 quoted lines
> From what I understand, this bit is used exactly for sparse checkouts > (as described in Documentation/technical/index-format.txt[1]). But > should we perhaps ignore it in git-grep to have the expected behavior? > I'll be happy to send the patch if so, but I wanted to check with you > first. > > Grepping with --cached or in given trees objects would still grep > outside the cone, but that is what one would expect, right? Or should > we filter out what is outside of the cone for cached grep as well? > > Thanks, > Matheus > > [1]: https://github.com/git/git/blob/master/Documentation/technical/index-format.txt#L101