Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on Jan 26, 2010
  1. @gitster

    Threaded grep

    Fredrik Kuivinen authored gitster committed
    Make git grep use threads when it is available.
    
    The results below are best of five runs in the Linux repository (on a
    box with two cores).
    
    With the patch:
    
    git grep qwerty
    1.58user 0.55system 0:01.16elapsed 183%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+800outputs (0major+5774minor)pagefaults 0swaps
    
    Without:
    
    git grep qwerty
    1.59user 0.43system 0:02.02elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+800outputs (0major+3716minor)pagefaults 0swaps
    
    And with a pattern with quite a few matches:
    
    With the patch:
    
    $ /usr/bin/time git grep void
    5.61user 0.56system 0:03.44elapsed 179%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+800outputs (0major+5587minor)pagefaults 0swaps
    
    Without:
    
    $ /usr/bin/time git grep void
    5.36user 0.51system 0:05.87elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+800outputs (0major+3693minor)pagefaults 0swaps
    
    In either case we gain about 40% by the threading.
    
    Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 13, 2010
  1. @gitster

    grep: rip out support for external grep

    gitster authored
    We still allow people to pass --[no-]ext-grep on the command line,
    but the option is ignored.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Nov 17, 2009
  1. @briancollins @gitster

    grep: Allow case insensitive search of fixed-strings

    briancollins authored gitster committed
    "git grep" currently an error when you combine the -F and -i flags.
    This isn't in line with how GNU grep handles it.
    
    This patch allows the simultaneous use of those flags.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Brian Collins <bricollins@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Sep 13, 2009
  1. @gitster

    Merge branch 'maint'

    gitster authored
    * maint:
      GIT 1.6.4.3
      svn: properly escape arguments for authors-prog
      http.c: remove verification of remote packs
      grep: accept relative paths outside current working directory
      grep: fix exit status if external_grep() punts
    
    Conflicts:
    	GIT-VERSION-GEN
    	RelNotes
  2. @gitster

    Merge branch 'cb/maint-1.6.3-grep-relative-up' into maint

    gitster authored
    * cb/maint-1.6.3-grep-relative-up:
      grep: accept relative paths outside current working directory
      grep: fix exit status if external_grep() punts
    
    Conflicts:
    	t/t7002-grep.sh
Commits on Sep 7, 2009
  1. @drizzd @gitster

    grep: accept relative paths outside current working directory

    drizzd authored gitster committed
    "git grep" would barf at relative paths pointing outside the current
    working directory (or subdirectories thereof). Use quote_path_relative(),
    which can handle such cases just fine.
    
    [jc: added tests.]
    
    Signed-off-by: Clemens Buchacher <drizzd@aon.at>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 23, 2009
  1. @gitster

    grep: Add --max-depth option.

    Michał Kiedrowicz authored gitster committed
    It is useful to grep directories non-recursively, e.g. when one wants to
    look for all files in the toplevel directory, but not in any subdirectory,
    or in Documentation/, but not in Documentation/technical/.
    
    This patch adds support for --max-depth <depth> option to git-grep. If it is
    given, git-grep descends at most <depth> levels of directories below paths
    specified on the command line.
    
    Note that if path specified on command line contains wildcards, this option
    makes no sense, e.g.
    
        $ git grep -l --max-depth 0 GNU -- 'contrib/*'
    
    (note the quotes) will search all files in contrib/, even in
    subdirectories, because '*' matches all files.
    
    Documentation updates, bash-completion and simple test cases are also
    provided.
    
    Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 2, 2009
  1. @gitster

    grep -p: support user defined regular expressions

    René Scharfe authored gitster committed
    Respect the userdiff attributes and config settings when looking for
    lines with function definitions in git grep -p.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @gitster

    grep: add option -p/--show-function

    René Scharfe authored gitster committed
    The new option -p instructs git grep to print the previous function
    definition as a context line, similar to diff -p.  Such context lines
    are marked with an equal sign instead of a dash.  This option
    complements the existing context options -A, -B, -C.
    
    Function definitions are detected using the same heuristic that diff
    uses.  User defined regular expressions are not supported, yet.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @gitster

    grep: print context hunk marks between files

    René Scharfe authored gitster committed
    Print a hunk mark before matches from a new file are shown, in addition
    to the current behaviour of printing them if lines have been skipped.
    
    The result is easier to read, as (presumably unrelated) matches from
    different files are separated by a hunk mark.  GNU grep does the same.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. @gitster

    grep: move context hunk mark handling into show_line()

    René Scharfe authored gitster committed
    Move last_shown into struct grep_opt, to make it available in
    show_line(), and then make the function handle the printing of hunk
    marks for context lines in a central place.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 9, 2009
  1. @gitster

    grep: use parseopt

    René Scharfe authored gitster committed
    Convert git-grep to parseopt.
    
    The bitfields in struct grep_opt are converted to full ints,
    increasing its size.  This shouldn't be a problem as there is only a
    single instance in memory.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 7, 2009
  1. @gitster

    grep: add support for coloring with external greps

    René Scharfe authored gitster committed
    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: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. @gitster

    grep: color patterns in output

    René Scharfe authored gitster committed
    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: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. @gitster

    grep: remove grep_opt argument from match_expr_eval()

    René Scharfe authored gitster committed
    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: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 10, 2009
  1. @gitster

    grep: don't call regexec() for fixed strings

    René Scharfe authored gitster committed
    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: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 1, 2008
  1. @spearce

    git grep: Add "-z/--null" option as in GNU's grep.

    Raphael Zimmerer authored spearce committed
    Here's a trivial patch that adds "-z" and "--null" options to "git
    grep". It was discussed on the mailing-list that git's "-z"
    convention should be used instead of GNU grep's "-Z".
    So things like 'git grep -l -z "$FOO" | xargs -0 sed -i "s/$FOO/$BOO/"'
    do work now.
    
    Signed-off-by: Raphael Zimmerer <killekulla@rdrz.de>
    Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Commits on Sep 5, 2008
  1. @gitster

    log --author/--committer: really match only with name part

    gitster authored
    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: Junio C Hamano <gitster@pobox.com>
Commits on Sep 28, 2006
  1. grep --all-match

    Junio C Hamano authored
    This lets you say:
    
    	git grep --all-match -e A -e B -e C
    
    to find lines that match A or B or C but limit the matches from
    the files that have all of A, B and C.
    
    This is different from
    
    	git grep -e A --and -e B --and -e C
    
    in that the latter looks for a single line that has all of these
    at the same time.
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Sep 27, 2006
  1. grep: free expressions and patterns when done.

    Junio C Hamano authored
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Sep 20, 2006
  1. Update grep internal for grepping only in head/body

    Junio C Hamano authored
    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: Junio C Hamano <junkio@cox.net>
  2. builtin-grep: make pieces of it available as library.

    Junio C Hamano authored
    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: Junio C Hamano <junkio@cox.net>
Something went wrong with that request. Please try again.