git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/5] grep: skip files outside sparse checkout area

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 31, 2009, 16:42 UTC
Message-ID
<7vljm4st0w.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1248850154-5469-3-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
> ---
>  Documentation/git-grep.txt |    4 +++-
>  builtin-grep.c             |    7 ++++++-
>  2 files changed, 9 insertions(+), 2 deletions(-)

I do not think you can call this "CE_VALID fixup". This is a possibly useful but nevertheless a new, different behaviour.

We probably want opt->ignoreassumeunchanged in struct grep_opt, and control it via grep.ignoreassumeunchanged configuration, that perhaps defaults to true (i.e. "ignore"), with a command line override.

Oh, and perhaps a shorter-and-sweeter name than "ignoreAssumeUnchanged".
Show 10 quoted lines
> diff --git a/builtin-grep.c b/builtin-grep.c
> index ad0e0a5..55078cb 100644
> --- a/builtin-grep.c
> +++ b/builtin-grep.c
> @@ -455,6 +455,8 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
>  			continue;
>  		if (!pathspec_matches(paths, ce->name, opt->max_depth))
>  			continue;
> +		if (ce->ce_flags & CE_VALID)
> +			continue;
The test probably should come before pathspec_matches().
Show 13 quoted lines
> @@ -522,8 +524,11 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached,
>  				continue;
>  			hit |= grep_sha1(opt, ce->sha1, ce->name, 0);
>  		}
> -		else
> +		else {
> +			if (ce->ce_flags & CE_VALID)
> +				continue;
>  			hit |= grep_file(opt, ce->name);
> +		}
>  		if (ce_stage(ce)) {
>  			do {
>  				nr++;

I do not think the new code in this hunk will be reached as the other arm of the "else" greps in the index when CE_VALID is set.

Has this series been tested or self-reviewed yet?
Previous: Junio C HamanoNext: Nguyen Thai Ngoc Duy
Message 11 of 15 in “Sparse checkout resurrection”
  1. 0/5 Sparse checkout resurrectionNguyễn Thái Ngọc Duy, Jul 29, 2009
  2. 1/5 Prevent diff machinery from examining worktree outside sparse checkoutNguyễn Thái Ngọc Duy, Jul 29, 2009
  3. 2/5 grep: skip files outside sparse checkout areaNguyễn Thái Ngọc Duy, Jul 29, 2009
  4. 3/5 gitignore: read from index if .gitignore is not in worktreeNguyễn Thái Ngọc Duy, Jul 29, 2009
  5. 4/5 unpack_trees(): keep track of unmerged entriesNguyễn Thái Ngọc Duy, Jul 29, 2009
  6. 5/5 unpack_trees(): add support for sparse checkoutNguyễn Thái Ngọc Duy, Jul 29, 2009
  7. Jakub NarebskiJul 29, 2009
  8. Nguyen Thai Ngoc DuyJul 29, 2009
  9. Jakub NarebskiJul 30, 2009
  10. Junio C HamanoJul 31, 2009
  11. Junio C HamanoJul 31, 2009
  12. Nguyen Thai Ngoc DuyAug 4, 2009
  13. Junio C HamanoJul 31, 2009
  14. skillzero@gmail.comJul 31, 2009
  15. Nguyen Thai Ngoc DuyAug 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.