1. 08 3月, 2009 3 次提交
    • R
      grep: add support for coloring with external greps · a94982ef
      René Scharfe 提交于
      Add the config variable color.grep.external, which can be used to
      switch on coloring of external greps.  To enable auto coloring with
      GNU grep, one needs to set color.grep.external to --color=always to
      defeat the pager started by git grep.  The value of the config
      variable will be passed to the external grep only if it would
      colorize internal grep's output, so automatic terminal detected
      works.  The default is to not pass any option, because the external
      grep command could be a program without color support.
      
      Also set the environment variables GREP_COLOR and GREP_COLORS to
      pass the configured color for matches to the external grep.  This
      works with GNU grep; other variables could be added as needed.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a94982ef
    • R
      grep: color patterns in output · 7e8f59d5
      René Scharfe 提交于
      Coloring matches makes them easier to spot in the output.
      
      Add two options and two parameters: color.grep (to turn coloring on
      or off), color.grep.match (to set the color of matches), --color
      and --no-color (to turn coloring on or off, respectively).
      
      The output of external greps is not changed.
      
      This patch is based on earlier ones by Nguyễn Thái Ngọc Duy and
      Thiago Alves.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7e8f59d5
    • R
      grep: remove grep_opt argument from match_expr_eval() · d7eb527d
      René Scharfe 提交于
      The only use of the struct grep_opt argument of match_expr_eval()
      is to pass the option word_regexp to match_one_pattern().  By adding
      a pattern flag for it we can reduce the number of function arguments
      of these two functions, as a cleanup and preparation for adding more
      in the next patch.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d7eb527d
  2. 10 1月, 2009 1 次提交
    • R
      grep: don't call regexec() for fixed strings · c822255c
      René Scharfe 提交于
      Add the new flag "fixed" to struct grep_pat and set it if the pattern
      is doesn't contain any regex control characters in addition to if the
      flag -F/--fixed-strings was specified.
      
      This gives a nice speed up on msysgit, where regexec() seems to be
      extra slow.  Before (best of five runs):
      
      	$ time git grep grep v1.6.1 >/dev/null
      
      	real    0m0.552s
      	user    0m0.000s
      	sys     0m0.000s
      
      	$ time git grep -F grep v1.6.1 >/dev/null
      
      	real    0m0.170s
      	user    0m0.000s
      	sys     0m0.015s
      
      With the patch:
      
      	$ time git grep grep v1.6.1 >/dev/null
      
      	real    0m0.173s
      	user    0m0.000s
      	sys     0m0.000s
      
      The difference is much smaller on Linux, but still measurable.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c822255c
  3. 02 10月, 2008 1 次提交
  4. 05 9月, 2008 1 次提交
    • J
      log --author/--committer: really match only with name part · a4d7d2c6
      Junio C Hamano 提交于
      When we tried to find commits done by AUTHOR, the first implementation
      tried to pattern match a line with "^author .*AUTHOR", which later was
      enhanced to strip leading caret and look for "^author AUTHOR" when the
      search pattern was anchored at the left end (i.e. --author="^AUTHOR").
      
      This had a few problems:
      
       * When looking for fixed strings (e.g. "git log -F --author=x --grep=y"),
         the regexp internally used "^author .*x" would never match anything;
      
       * To match at the end (e.g. "git log --author='google.com>$'"), the
         generated regexp has to also match the trailing timestamp part the
         commit header lines have.  Also, in order to determine if the '$' at
         the end means "match at the end of the line" or just a literal dollar
         sign (probably backslash-quoted), we would need to parse the regexp
         ourselves.
      
      An earlier alternative tried to make sure that a line matches "^author "
      (to limit by field name) and the user supplied pattern at the same time.
      While it solved the -F problem by introducing a special override for
      matching the "^author ", it did not solve the trailing timestamp nor tail
      match problem.  It also would have matched every commit if --author=author
      was asked for, not because the author's email part had this string, but
      because every commit header line that talks about the author begins with
      that field name, regardleses of who wrote it.
      
      Instead of piling more hacks on top of hacks, this rethinks the grep
      machinery that is used to look for strings in the commit header, and makes
      sure that (1) field name matches literally at the beginning of the line,
      followed by a SP, and (2) the user supplied pattern is matched against the
      remainder of the line, excluding the trailing timestamp data.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a4d7d2c6
  5. 28 9月, 2006 2 次提交
  6. 21 9月, 2006 2 次提交
    • J
      Update grep internal for grepping only in head/body · 480c1ca6
      Junio C Hamano 提交于
      This further updates the built-in grep engine so that we can say
      something like "this pattern should match only in head".  This
      can be used to simplify grepping in the log messages.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      480c1ca6
    • J
      builtin-grep: make pieces of it available as library. · 83b5d2f5
      Junio C Hamano 提交于
      This makes three functions and associated option structures from
      builtin-grep available from other parts of the system.
      
       * options to drive built-in grep engine is stored in struct
         grep_opt;
      
       * pattern strings and extended grep expressions are added to
         struct grep_opt with append_grep_pattern();
      
       * when finished calling append_grep_pattern(), call
         compile_grep_patterns() to prepare for execution;
      
       * call grep_buffer() to find matches in the in-core buffer.
      
      This also adds an internal option "status_only" to grep_opt,
      which suppresses any output from grep_buffer().  Callers of the
      function as library can use it to check if there is a match
      without producing any output.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      83b5d2f5