Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on Mar 24, 2014
  1. Junio C Hamano

    pickaxe: simplify kwset loop in contains()

    René Scharfe authored gitster committed
    Inlining the variable "found" actually makes the code shorter and
    easier to read.
    
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. Junio C Hamano

    pickaxe: call strlen only when necessary in diffcore_pickaxe_count()

    René Scharfe authored gitster committed
    We need to determine the search term's length only when fixed-string
    matching is used; regular expression compilation takes a NUL-terminated
    string directly.  Only call strlen() in the former case.
    
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. Junio C Hamano

    pickaxe: move pickaxe() after pickaxe_match()

    René Scharfe authored gitster committed
    pickaxe() calls pickaxe_match(); moving the definition of the former
    after the latter allows us to do without an explicit function
    declaration.
    
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. Junio C Hamano

    pickaxe: merge diffcore_pickaxe_grep() and diffcore_pickaxe_count() i…

    René Scharfe authored gitster committed
    …nto diffcore_pickaxe()
    
    diffcore_pickaxe_count() initializes the regular expression or kwset for
    the search term, calls pickaxe() with the callback has_changes() and
    cleans up afterwards.  diffcore_pickaxe_grep() does the same, only it
    doesn't support kwset and uses the callback diff_grep() instead.  Merge
    the two functions to form the new diffcore_pickaxe() and thus get rid of
    the duplicate regex setup and cleanup code.
    
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. Junio C Hamano

    pickaxe: honor -i when used with -S and --pickaxe-regex

    René Scharfe authored gitster committed
    accccde (pickaxe: allow -i to search in patch case-insensitively)
    allowed case-insenitive matching for -G and -S, but for the latter
    only if fixed string matching is used.  Allow it for -S and regular
    expression matching as well to make the support complete.
    
    Signed-off-by: Rene Scharfe <l.s.r@web.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 12, 2013
  1. Junio C Hamano

    Merge branch 'rs/pickaxe-simplify'

    gitster authored
    * rs/pickaxe-simplify:
      diffcore-pickaxe: simplify has_changes and contains
Commits on Jul 7, 2013
  1. Junio C Hamano

    diffcore-pickaxe: simplify has_changes and contains

    René Scharfe authored gitster committed
    Halve the number of callsites of contains() to two using temporary
    variables, simplifying the code.  While at it, get rid of the
    diff_options parameter, which became unused with 8fa4b09.
    
    Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
    Acked-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 3, 2013
  1. Ramkumar Ramachandra Junio C Hamano

    diffcore-pickaxe: make error messages more consistent

    artagnon authored gitster committed
    Currently, diffcore-pickaxe reports two distinct errors for the same
    user error:
    
        $ git log --pickaxe-regex -S'\1'
        fatal: invalid pickaxe regex: Invalid back reference
    
        $ git log -G'\1'
        fatal: invalid log-grep regex: Invalid back reference
    
    This "log-grep" was only an internal name for the -G feature during
    development, and invite confusion with "git log --grep=<pattern>".
    
    Change the error messages to say "invalid regex".
    
    Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Apr 5, 2013
  1. Jeff King Junio C Hamano

    diffcore-pickaxe: unify code for log -S/-G

    peff authored gitster committed
    The logic flow of has_changes() used for "log -S" and diff_grep()
    used for "log -G" are essentially the same.  See if we have both
    sides that could be different in any interesting way, slurp the
    contents in core, possibly after applying textconv, inspect the
    contents, clean-up and report the result.  The only difference
    between the two is how "inspect" step works.
    
    Unify this codeflow in a helper, pickaxe_match(), which takes a
    callback function that implements the specific "inspect" step.
    
    After removing the common scaffolding code from the existing
    has_changes() and diff_grep(), they each becomes such a callback
    function suitable for passing to pickaxe_match().
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. Junio C Hamano

    diffcore-pickaxe: fix leaks in "log -S<block>" and "log -G<pattern>"

    gitster authored
    The diff_grep() and has_changes() functions had early return
    codepaths for unmerged filepairs, which simply returned 0.  When we
    taught textconv filter to them, one was ignored and continued to
    return early without freeing the result filtered by textconv, and
    the other had a failed attempt to fix, which allowed the planned
    return value 0 to be overwritten by a bogus call to contains().
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. Junio C Hamano

    diffcore-pickaxe: port optimization from has_changes() to diff_grep()

    gitster authored
    These two functions are called in the same codeflow to implement
    "log -S<block>" and "log -G<pattern>", respectively, but the latter
    lacked two obvious optimizations the former implemented, namely:
    
     - When a pickaxe limit is not given at all, they should return
       without wasting any cycle;
    
     - When both sides of the filepair are the same, and the same
       textconv conversion apply to them, return early, as there will be
       no interesting differences between the two anyway.
    
    Also release the filespec data once the processing is done (this is
    not about leaking memory--it is about releasing data we finished
    looking at as early as possible).
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. rudis Junio C Hamano

    diffcore-pickaxe: respect --no-textconv

    rudis authored gitster committed
    git log -S doesn't respect --no-textconv:
    
        $ echo '*.txt diff=wrong' > .gitattributes
        $ git -c diff.wrong.textconv='xxx' log --no-textconv -Sfoo
        error: cannot run xxx: No such file or directory
        fatal: unable to read files to diff
    
    Reported-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
    Signed-off-by: Simon Ruderich <simon@ruderich.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. Jeff King Junio C Hamano

    diffcore-pickaxe: remove fill_one()

    peff authored gitster committed
    fill_one is _almost_ identical to just calling fill_textconv; the
    exception is that for the !DIFF_FILE_VALID case, fill_textconv gives us
    an empty buffer rather than a NULL one. Since we currently use the NULL
    pointer as a signal that the file is not present on one side of the
    diff, we must now switch to using DIFF_FILE_VALID to make the same
    check.
    
    Signed-off-by: Jeff King <peff@peff.net>
    Signed-off-by: Simon Ruderich <simon@ruderich.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6. rudis Junio C Hamano

    diffcore-pickaxe: remove unnecessary call to get_textconv()

    rudis authored gitster committed
    The fill_one() function is responsible for finding and filling the
    textconv filter as necessary, and is called by diff_grep() function
    that implements "git log -G<pattern>".
    
    The has_changes() function that implements "git log -S<block>" calls
    get_textconv() for two sides being compared, before it checks to see
    if it was asked to perform the pickaxe limiting.  Move the code
    around to avoid this wastage.
    
    After has_changes() calls get_textconv() to obtain textconv for both
    sides, fill_one() is called to use them.
    
    By adding get_textconv() to diff_grep() and relieving fill_one() of
    responsibility to find the textconv filter, we can avoid calling
    get_textconv() twice in has_changes().
    
    With this change it's also no longer necessary for fill_one() to
    modify the textconv argument, therefore pass a pointer instead of a
    pointer to a pointer.
    
    Signed-off-by: Simon Ruderich <simon@ruderich.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 28, 2012
  1. Jeff King

    pickaxe: use textconv for -S counting

    peff authored
    We currently just look at raw blob data when using "-S" to
    pickaxe. This is mostly historical, as pickaxe predates the
    textconv feature. If the user has bothered to define a
    textconv filter, it is more likely that their search string will be
    on the textconv output, as that is what they will see in the
    diff (and we do not even provide a mechanism for them to
    search for binary needles that contain NUL characters).
    
    This patch teaches "-S" to use textconv, just as we
    already do for "-G".
    
    Signed-off-by: Jeff King <peff@peff.net>
  2. Jeff King

    pickaxe: hoist empty needle check

    peff authored
    If we are given an empty pickaxe needle like "git log -S ''",
    it is impossible for us to find anything (because no matter
    what the content, the count will always be 0). We currently
    check this at the lowest level of contains(). Let's hoist
    the logic much earlier to has_changes(), so that it is
    simpler to return our answer before loading any blob data.
    
    Signed-off-by: Jeff King <peff@peff.net>
  3. Jeff King

    diff_grep: use textconv buffers for add/deleted files

    peff authored
    If you use "-G" to grep a diff, we will apply a configured
    textconv filter to the data before generating the diff.
    However, if the diff is an addition or deletion, we do not
    bother running the diff at all, and just look for the token
    in the added (or removed) content. This works because we
    know that the diff must contain every line of content.
    
    However, while we used the textconv-derived buffers in the
    regular diff, we accidentally passed the original unmodified
    buffers to regexec when checking the added or removed
    content. This could lead to an incorrect answer.
    
    Worse, in some cases we might have a textconv buffer but no
    original buffer (e.g., if we pulled the textconv data from
    cache, or if we reused a working tree file when generating
    it). In that case, we could actually feed NULL to regexec
    and segfault.
    
    Reported-by: Peter Oberndorfer <kumbayo84@arcor.de>
    Signed-off-by: Jeff King <peff@peff.net>
Commits on Feb 29, 2012
  1. Junio C Hamano

    pickaxe: allow -i to search in patch case-insensitively

    gitster authored
    "git log -S<string>" is a useful way to find the last commit in the
    codebase that touched the <string>. As it was designed to be used by a
    porcelain script to dig the history starting from a block of text that
    appear in the starting commit, it never had to look for anything but an
    exact match.
    
    When used by an end user who wants to look for the last commit that
    removed a string (e.g. name of a variable) that he vaguely remembers,
    however, it is useful to support case insensitive match.
    
    When given the "--regexp-ignore-case" (or "-i") option, which originally
    was designed to affect case sensitivity of the search done in the commit
    log part, e.g. "log --grep", the matches made with -S/-G pickaxe search is
    done case insensitively now.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 7, 2011
  1. Junio C Hamano

    pickaxe: factor out pickaxe

    René Scharfe authored gitster committed
    Move the duplicate diff queue loop into its own function that accepts
    a match function: has_changes() for -S and diff_grep() for -G.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. Junio C Hamano

    pickaxe: give diff_grep the same signature as has_changes

    René Scharfe authored gitster committed
    Change diff_grep() to match the signature of has_changes() as a
    preparation for the next patch that will use function pointers to
    the two.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. Junio C Hamano

    pickaxe: pass diff_options to contains and has_changes

    René Scharfe authored gitster committed
    Remove the unused parameter needle from contains() and has_changes().
    
    Also replace the parameter len with a pointer to the diff_options.  We
    can use its member pickaxe to check if the needle is an empty string
    and use the kwsmatch structure to find out the length of the match
    instead.
    
    This change is done as a preparation to unify the signatures of
    has_changes() and diff_grep(), which will be used in the patch after
    the next one to factor out common code.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. Junio C Hamano

    pickaxe: factor out has_changes

    René Scharfe authored gitster committed
    Move duplicate if/else construct into its own helper function.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. Junio C Hamano

    pickaxe: plug regex/kws leak

    René Scharfe authored gitster committed
    With -S... --pickaxe-all, free the regex or the kws before returning
    even if we found a match.  Also get rid of the variable has_changes,
    as we can simply break out of the loop.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  6. Junio C Hamano

    pickaxe: plug regex leak

    René Scharfe authored gitster committed
    With -G... --pickaxe-all, free the regex before returning even if we
    found a match.  Also get rid of the variable has_changes, as we can
    simply break out of the loop.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  7. Junio C Hamano

    pickaxe: plug diff filespec leak with empty needle

    René Scharfe authored gitster committed
    Check first for the unlikely case of an empty needle string and only
    then populate the filespec, lest we leak it.
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 21, 2011
  1. Junio C Hamano

    Use kwset in pickaxe

    Fredrik Kuivinen authored gitster committed
    Benchmarks in the hot cache case:
    
    before:
    $ perf stat --repeat=5 git log -Sqwerty
    
    Performance counter stats for 'git log -Sqwerty' (5 runs):
    
           47,092,744 cache-misses             #      2.825 M/sec   ( +-   1.607% )
          123,368,389 cache-references         #      7.400 M/sec   ( +-   0.812% )
          330,040,998 branch-misses            #      3.134 %       ( +-   0.257% )
       10,530,896,750 branches                 #    631.663 M/sec   ( +-   0.121% )
       62,037,201,030 instructions             #      1.399 IPC     ( +-   0.142% )
       44,331,294,321 cycles                   #   2659.073 M/sec   ( +-   0.326% )
               96,794 page-faults              #      0.006 M/sec   ( +-  11.952% )
                   25 CPU-migrations           #      0.000 M/sec   ( +-  25.266% )
                1,424 context-switches         #      0.000 M/sec   ( +-   0.540% )
         16671.708650 task-clock-msecs         #      0.997 CPUs    ( +-   0.343% )
    
          16.728692052  seconds time elapsed   ( +-   0.344% )
    
    after:
    $ perf stat --repeat=5 git log -Sqwerty
    
    Performance counter stats for 'git log -Sqwerty' (5 runs):
    
           51,385,522 cache-misses             #      4.619 M/sec   ( +-   0.565% )
          129,177,880 cache-references         #     11.611 M/sec   ( +-   0.219% )
          319,222,775 branch-misses            #      6.946 %       ( +-   0.134% )
        4,595,913,233 branches                 #    413.086 M/sec   ( +-   0.112% )
       31,395,042,533 instructions             #      1.062 IPC     ( +-   0.129% )
       29,558,348,598 cycles                   #   2656.740 M/sec   ( +-   0.204% )
               93,224 page-faults              #      0.008 M/sec   ( +-   4.487% )
                   19 CPU-migrations           #      0.000 M/sec   ( +-  10.425% )
                  950 context-switches         #      0.000 M/sec   ( +-   0.360% )
         11125.796039 task-clock-msecs         #      0.997 CPUs    ( +-   0.239% )
    
          11.164216599  seconds time elapsed   ( +-   0.240% )
    
    So the kwset code is about 33% faster.
    
    Signed-off-by: Fredrik Kuivinen <frekui@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 6, 2010
  1. Brandon Casey Junio C Hamano

    diffcore-pickaxe.c: a void function shouldn't try to return something

    drafnel authored gitster committed
    Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. Junio C Hamano

    Merge branch 'maint'

    gitster authored
    * maint:
      Documentation/git-clone: describe --mirror more verbosely
      do not depend on signed integer overflow
      work around buggy S_ISxxx(m) implementations
      xdiff: cast arguments for ctype functions to unsigned char
      init: plug tiny one-time memory leak
      diffcore-pickaxe.c: remove unnecessary curly braces
      t3020 (ls-files-error-unmatch): remove stray '1' from end of file
      setup: make sure git dir path is in a permanent buffer
      environment.c: remove unused variable
      git-svn: fix processing of decorated commit hashes
      git-svn: check_cherry_pick should exclude commits already in our history
      Documentation/git-svn: discourage "noMetadata"
Commits on Oct 5, 2010
  1. Brandon Casey Junio C Hamano

    diffcore-pickaxe.c: remove unnecessary curly braces

    drafnel authored gitster committed
    Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Aug 31, 2010
  1. Junio C Hamano

    git log/diff: add -G<regexp> that greps in the patch text

    gitster authored
    Teach "-G<regexp>" that is similar to "-S<regexp> --pickaxe-regexp" to the
    "git diff" family of commands.  This limits the diff queue to filepairs
    whose patch text actually has an added or a deleted line that matches the
    given regexp.  Unlike "-S<regexp>", changing other parts of the line that
    has a substring that matches the given regexp IS counted as a change, as
    such a change would appear as one deletion followed by one addition in a
    patch text.
    
    Unlike -S (pickaxe) that is intended to be used to quickly detect a commit
    that changes the number of occurrences of hits between the preimage and
    the postimage to serve as a part of larger toolchain, this is meant to be
    used as the top-level Porcelain feature.
    
    The implementation unfortunately has to run "diff" twice if you are
    running "log" family of commands to produce patches in the final output
    (e.g. "git log -p" or "git format-patch").  I think we _could_ cache the
    result in-core if we wanted to, but that would require larger surgery to
    the diffcore machinery (i.e. adding an extra pointer in the filepair
    structure to keep a pointer to a strbuf around, stuff the textual diff to
    the strbuf inside diffgrep_consume(), and make use of it in later stages
    when it is available) and it may not be worth it.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. Junio C Hamano

    diff: pass the entire diff-options to diffcore_pickaxe()

    gitster authored
    That would make it easier to give enhanced feature to the
    pickaxe transformation.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on May 7, 2010
  1. byang Junio C Hamano

    Add a macro DIFF_QUEUE_CLEAR.

    byang authored gitster committed
    Refactor the diff_queue_struct code, this macro help
    to reset the structure.
    
    Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 17, 2009
  1. Junio C Hamano

    pickaxe: count regex matches only once

    René Scharfe authored gitster committed
    When --pickaxe-regex is used, forward past the end of matches instead of
    advancing to the byte after their start.  This way matches count only
    once, even if the regular expression matches their tail -- like in the
    fixed-string fork of the code.
    
    E.g.: /.*/ used to count the number of bytes instead of the number of
    lines.  /aa/ resulted in a count of two in "aaa" instead of one.
    
    Also document the fact that regexec() needs a NUL-terminated string as
    its second argument by adding an assert().
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Mar 3, 2009
  1. Junio C Hamano

    diffcore-pickaxe: use memmem()

    René Scharfe authored gitster committed
    Use memmem() instead of open-coding it.  The system libraries usually have a
    much faster version than the memcmp()-loop here.  Even our own fall-back in
    compat/, which is used on Windows, is slightly faster.
    
    The following commands were run in a Linux kernel repository and timed, the
    best of five results is shown:
    
      $ STRING='Ensure that the real time constraints are schedulable.'
      $ git log -S"$STRING" HEAD -- kernel/sched.c >/dev/null
    
    On Ubuntu 8.10 x64, before (v1.6.2-rc2):
    
      8.09user 0.04system 0:08.14elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+30952minor)pagefaults 0swaps
    
    And with the patch:
    
      1.50user 0.04system 0:01.54elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+30645minor)pagefaults 0swaps
    
    On Fedora 10 x64, before:
    
      8.34user 0.05system 0:08.39elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+29268minor)pagefaults 0swaps
    
    And with the patch:
    
      1.15user 0.05system 0:01.20elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
      0inputs+0outputs (0major+32253minor)pagefaults 0swaps
    
    On Windows Vista x64, before:
    
      real    0m9.204s
      user    0m0.000s
      sys     0m0.000s
    
    And with the patch:
    
      real    0m8.470s
      user    0m0.000s
      sys     0m0.000s
    
    Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 7, 2007
  1. Junio C Hamano

    War on whitespace

    gitster authored
    This uses "git-apply --whitespace=strip" to fix whitespace errors that have
    crept in to our source files over time.  There are a few files that need
    to have trailing whitespaces (most notably, test vectors).  The results
    still passes the test, and build result in Documentation/ area is unchanged.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Something went wrong with that request. Please try again.