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

Re: [PATCH] grep: do not do external grep on skip-worktree entries

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Jan 2, 2010, 19:15 UTC
Message-ID
<fcaeb9bf1001021115j7b23264n42cfba7855c2253e@mail.gmail.com>
In-Reply-To
<7vtyv4cpna.fsf@alter.siamese.dyndns.org>
On 1/3/10, Junio C Hamano <gitster@pobox.com> wrote:
Show 38 quoted lines
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
>
>  > On Wed, Dec 30, 2009 at 11:09:52PM -0800, Junio C Hamano wrote:
>  >> Junio C Hamano <gitster@pobox.com> writes:
>  >>
>  >> > This looks a bit wrong for a couple of reasons:
>  >> >
>  >> >  - external_grep() is designed to return negative without running external
>  >> >    grep when it shouldn't be used (see the beginning of the function for
>  >> >    how it refuses to run when opt->extended is set and other conditions).
>  >> >    The new logic seems to belong there, i.e. "in addition to the existing
>  >> >    case we decline, if ce_skip_worktree() entry exists in the cache, we
>  >> >    decline";
>  >>
>  >> IOW, something like this instead of your patch.  You would want to tests
>  >> to demonstrate the original breakage, perhaps?
>  >
>  > Your patch works great. By the way I think we should move "cached"
>  > check from grep_cache() into external_grep() too, for consistency.
>
>
> I think what I gave you is more consistent.
>
>  "cached" is about "are we searching in the index or in the work tree?" and
>  "external_grep()" is about "it often is faster to run external grep when
>  we are searching in the work tree, so do that if the other constraints
>  allow us to".  An example of such a constraint is that we must be able to
>  express the operation on the command line of a traditional grep, and use
>  of git extended grep synatx makes it unfeasible, hence the function says
>  "I can't" in such a case.
>
>  You can change the definition of "external_grep()" to "try to use external
>  grep somewhere, if the other constraints allow us to", and have the caller
>  and the function do an "this time, please grep for this pattern in the
>  index---I can't" exchange, but I don't see much point.  We _know_ no
>  external grep will ever be able to read from the index.
>
>  We should simply drop "cached" argument from external_grep().
OK.
Show 23 quoted lines
>  > diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
>  > index abd14bf..f77970c 100755
>  > --- a/t/t7002-grep.sh
>  > +++ b/t/t7002-grep.sh
>  > @@ -8,6 +8,14 @@ test_description='git grep various.
>  >
>  >  . ./test-lib.sh
>  >
>  > +support_external_grep() {
>  > +     case "$(git grep -h 2>&1 >/dev/null|grep -e --ext-grep)" in
>  > +     *"(default)"*)  return 0;;
>  > +     *"(ignored by this build)"*) return 1;;
>  > +     *) test_expect_success 'External grep check is broken' 'false';;
>  > +     esac
>  > +}
>
>
> Heh, clever.
>
>         git grep -h 2>&1 | grep 'allow calling of grep.*default' >/dev/null
>
>  may be sufficient, though.
>

Yes, until somebody changes help text in builtin-grep.c and all external grep tests become disable. I wanted to catch that case too.

Or maybe just add another option --show-features to "git rev-parse" (or extend git version string, is the version format fixed?) to list all built-time features that a git build supports. Some comes to mind: external-grep, iconv, ipv6, http (unlikely), threading... Much less tricky to test.

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 60 in “grep: do not do external grep on skip-worktree entries”
  1. grep: do not do external grep on skip-worktree entriesNguyễn Thái Ngọc Duy, Dec 30, 2009
  2. Junio C HamanoDec 31, 2009
  3. Junio C HamanoDec 31, 2009
  4. Nguyen Thai Ngoc DuyJan 2, 2010
  5. Junio C HamanoJan 2, 2010
  6. Nguyen Thai Ngoc DuyJan 2, 2010
  7. Junio C HamanoJan 2, 2010
  8. Miles BaderJan 3, 2010
  9. Miles BaderJan 3, 2010
  10. Miles BaderJan 3, 2010
  11. Linus TorvaldsJan 3, 2010
  12. Junio C HamanoJan 3, 2010
  13. Jeff KingJan 4, 2010
  14. Junio C HamanoJan 4, 2010
  15. Jeff KingJan 4, 2010
  16. Junio C HamanoJan 4, 2010
  17. Junio C HamanoJan 4, 2010
  18. Jeff KingJan 4, 2010
  19. Jeff KingJan 4, 2010
  20. Jeff KingJan 4, 2010
  21. Linus TorvaldsJan 4, 2010
  22. Linus TorvaldsJan 4, 2010
  23. Miles BaderJan 4, 2010
  24. Linus TorvaldsJan 4, 2010
  25. Junio C HamanoJan 11, 2010
  26. Linus TorvaldsJan 11, 2010
  27. Linus TorvaldsJan 11, 2010
  28. Junio C HamanoJan 11, 2010
  29. Junio C HamanoJan 11, 2010
  30. Linus TorvaldsJan 11, 2010
  31. Junio C HamanoJan 12, 2010
  32. grep: lookahead optimization can be used with -L optionJunio C Hamano, Jan 12, 2010
  33. grep: -L should show empty filesJunio C Hamano, Jan 12, 2010
  34. Sverre RabbelierJan 12, 2010
  35. Junio C HamanoJan 13, 2010
  36. Sverre RabbelierJan 13, 2010
  37. Junio C HamanoJan 13, 2010
  38. 1/2 grep: rip out support for external grepJunio C Hamano, Jan 13, 2010
  39. Jay SoffianJan 13, 2010
  40. Junio C HamanoJan 13, 2010
  41. Linus TorvaldsJan 13, 2010
  42. 2/2 grep: rip out pessimization to use fixmatch()Junio C Hamano, Jan 13, 2010
  43. Jeff KingJan 12, 2010
  44. Fredrik KuivinenJan 11, 2010
  45. Linus TorvaldsJan 4, 2010
  46. Nguyen Thai Ngoc DuyJan 4, 2010
  47. Mike HommeyJan 4, 2010
  48. Jeff KingJan 4, 2010
  49. 1/2 t7002: set test prerequisite "external-grep" if supportedNguyễn Thái Ngọc Duy, Jan 4, 2010
  50. Junio C HamanoJan 7, 2010
  51. Junio C HamanoJan 7, 2010
  52. Nguyen Thai Ngoc DuyJan 7, 2010
  53. Johannes SixtJan 7, 2010
  54. Nguyen Thai Ngoc DuyJan 7, 2010
  55. 2/2 t7002: add tests for skip-worktree fixes in commit a67e281Nguyễn Thái Ngọc Duy, Jan 4, 2010
  56. Linus TorvaldsJan 11, 2010
  57. Fredrik KuivinenJan 11, 2010
  58. Linus TorvaldsJan 11, 2010
  59. Fredrik KuivinenJan 11, 2010
  60. Linus TorvaldsJan 11, 2010

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.