1. 24 7月, 2013 3 次提交
  2. 10 7月, 2013 2 次提交
    • E
      range_set: fix coalescing bug when range is a subset of another · 3755b53a
      Eric Sunshine 提交于
      When coalescing ranges, sort_and_merge_range_set() unconditionally
      assumes that the end of a range being folded into a preceding range
      should become the end of the coalesced range. This assumption, however,
      is invalid when one range is a subset of another.  For example, given
      ranges 1-5 and 2-3 added via range_set_append_unsafe(),
      sort_and_merge_range_set() incorrectly coalesces them to range 1-3
      rather than the correct union range 1-5. Fix this bug.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3755b53a
    • E
      t4211: fix broken test when one -L range is subset of another · 18d472db
      Eric Sunshine 提交于
      t4211 attempts to test multiple git-log -L ranges where one range is a
      superset of the other, and falsely succeeds because its "expected"
      output is incorrect.
      
      Overlapping -L ranges handed to git-log are coalesced by
      line-log.c:sort_and_merge_range_set() into a set of non-overlapping,
      disjoint ranges. When one range is a subset of another,
      sort_and_merge_range_set() should coalesce both ranges to the superset
      range, but instead the coalesced range often is incorrectly truncated to
      the end of the subset range. For example, ranges 2-8 and 3-4 are
      coalesced incorrectly to 2-4.
      
      One can observe this incorrect behavior with git-log -L using the test
      repository created by t4211. The superset/subset ranges t4211 employs
      are 4-$ and 8-12 (where $ represents end-of-file). The coalesced range
      should be 4-$. Manually invoking git-log with the same ranges the test
      employs, we see:
      
        % git log -L 4:a.c simple |
          awk '/^commit [0-9a-f]{40}/ { print substr($2,1,7) }'
        4659538
        100b61a
        39b6eb2
        a6eb826
        f04fb20
        de4c48a
      
        % git log -L 8,12:a.c simple | awk ...
        f04fb20
        de4c48a
      
        % git log -L 4:a.c -L 8,12:a.c simple | awk ...
        a6eb826
        f04fb20
        de4c48a
      
      This last output is incorrect. 8-12 is a subset of 4-$, hence the output
      of the coalesced range should be the same as the 4-$ output shown first.
      In fact, the above incorrect output is the truncated bogus range 4-12:
      
        % git log -L 4,12:a.c simple | awk ...
        a6eb826
        f04fb20
        de4c48a
      
      Fix the test to correctly fail in the presence of the
      sort_and_merge_range_set() coalescing bug. Do so by changing the
      "expected" output to the commits mentioned in the 4-$ output above.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      18d472db
  3. 13 4月, 2013 4 次提交
    • T
      log -L: improve comments in process_all_files() · 1ddac3ff
      Thomas Rast 提交于
      The funny range assignment in process_all_files() had me sidetracked
      while investigating what led to the previous commit.  Let's improve
      the comments.
      Signed-off-by: NThomas Rast <trast@inf.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1ddac3ff
    • T
      log -L: store the path instead of a diff_filespec · 31c61918
      Thomas Rast 提交于
      line_log_data has held a diff_filespec* since the very early versions
      of the code.  However, the only place in the code where we actually
      need the full filespec is parse_range_arg(); in all other cases, we
      are only interested in the path, so there is hardly a reason to store
      a filespec.  Even worse, it causes a lot of redundant ->spec->path
      pointer dereferencing.
      
      And *even* worse, it caused the following bug.  If you merge a rename
      with a modification to the old filename, like so:
      
        * Merge
        | \
        |  * Modify foo
        |  |
        *  | Rename foo->bar
        | /
        * Create foo
      
      we internally -- in process_ranges_merge_commit() -- scan all parents.
      We are mainly looking for one that doesn't have any modifications, so
      that we can assign all the blame to it and simplify away the merge.
      In doing so, we run the normal machinery on all parents in a loop.
      For each parent, we prepare a "working set" line_log_data by making a
      copy with line_log_data_copy(), which does *not* make a copy of the
      spec.
      
      Now suppose the rename is the first parent.  The diff machinery tells
      us that the filepair is ('foo', 'bar').  We duly update the path we
      are interested in:
      
        rg->spec->path = xstrdup(pair->one->path);
      
      But that 'struct spec' is shared between the output line_log_data and
      the original input line_log_data.  So we just wrecked the state of
      process_ranges_merge_commit().  When we get around to the second
      parent, the ranges tell us we are interested in a file 'foo' while the
      commits touch 'bar'.
      
      So most of this patch is just s/->spec->path/->path/ and associated
      management changes.  This implicitly fixes the bug because we removed
      the shared parts between input and output of line_log_data_copy(); it
      is now safe to overwrite the path in the copy.
      
      There's one only somewhat related change: the comment in
      process_all_files() explains the reasoning behind using 'range' there.
      That bit of half-correct code had me sidetracked for a while.
      Signed-off-by: NThomas Rast <trast@inf.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      31c61918
    • T
      log -L: test merge of parallel modify/rename · d51c5274
      Thomas Rast 提交于
      This tests a toy example of a history like
      
        * Merge
        | \
        |  * Modify foo
        |  |
        *  | Rename foo->bar
        | /
        * Create foo
      
      Current log -L fails on this; we'll fix it in the next commit.
      Signed-off-by: NThomas Rast <trast@inf.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d51c5274
    • T
      t4211: pass -M to 'git log -M -L...' test · 035ff398
      Thomas Rast 提交于
      Embarrassingly, the -M test did not actually invoke -M, and thus not
      really test the feature.
      Signed-off-by: NThomas Rast <trast@inf.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      035ff398
  4. 06 4月, 2013 2 次提交
  5. 29 3月, 2013 5 次提交
    • T
      Speed up log -L... -M · 39410bf0
      Thomas Rast 提交于
      So far log -L only used the implicit diff filtering by pathspec.  If
      the user specifies -M, we cannot do that, and so we simply handed the
      whole diff queue (which is approximately 'git show --raw') to
      diffcore_std().
      
      Unfortunately this is very slow.  We can optimize a lot if we throw
      out files that we know cannot possibly be interesting, in the same
      spirit that the pathspec filtering reduces the number of files.
      
      However, in this case, we have to be more careful.  Because we want to
      look out for renames, we need to keep all filepairs where something
      was deleted.
      
      This is a bit hacky and should really be replaced by equivalent
      support in --follow, and just using that.  However, in the meantime it
      speeds up 'log -M -L' by an order of magnitude.
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      39410bf0
    • T
      log -L: :pattern:file syntax to find by funcname · 13b8f68c
      Thomas Rast 提交于
      This new syntax finds a funcname matching /pattern/, and then takes from there
      up to (but not including) the next funcname.  So you can say
      
        git log -L:main:main.c
      
      and it will dig up the main() function and show its line-log, provided
      there are no other funcnames matching 'main'.
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      13b8f68c
    • T
      Implement line-history search (git log -L) · 12da1d1f
      Thomas Rast 提交于
      This is a rewrite of much of Bo's work, mainly in an effort to split
      it into smaller, easier to understand routines.
      
      The algorithm is built around the struct range_set, which encodes a
      series of line ranges as intervals [a,b).  This is used in two
      contexts:
      
      * A set of lines we are tracking (which will change as we dig through
        history).
      * To encode diffs, as pairs of ranges.
      
      The main routine is range_set_map_across_diff().  It processes the
      diff between a commit C and some parent P.  It determines which diff
      hunks are relevant to the ranges tracked in C, and computes the new
      ranges for P.
      
      The algorithm is then simply to process history in topological order
      from newest to oldest, computing ranges and (partial) diffs.  At
      branch points, we need to merge the ranges we are watching.  We will
      find that many commits do not affect the chosen ranges, and mark them
      TREESAME (in addition to those already filtered by pathspec limiting).
      Another pass of history simplification then gets rid of such commits.
      
      This is wired as an extra filtering pass in the log machinery.  This
      currently only reduces code duplication, but should allow for other
      simplifications and options to be used.
      
      Finally, we hook a diff printer into the output chain.  Ideally we
      would wire directly into the diff logic, to optionally use features
      like word diff.  However, that will require some major reworking of
      the diff chain, so we completely replace the output with our own diff
      for now.
      
      As this was a GSoC project, and has quite some history by now, many
      people have helped.  In no particular order, thanks go to
      
        Jakub Narebski <jnareb@gmail.com>
        Jens Lehmann <Jens.Lehmann@web.de>
        Jonathan Nieder <jrnieder@gmail.com>
        Junio C Hamano <gitster@pobox.com>
        Ramsay Jones <ramsay@ramsay1.demon.co.uk>
        Will Palmer <wmpalmer@gmail.com>
      
      Apologies to everyone I forgot.
      Signed-off-by: NBo Yang <struggleyb.nku@gmail.com>
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      12da1d1f
    • B
      Export rewrite_parents() for 'log -L' · c7edcae0
      Bo Yang 提交于
      The function rewrite_one is used to rewrite a single
      parent of the current commit, and is used by rewrite_parents
      to rewrite all the parents.
      
      Decouple the dependence between them by making rewrite_one
      a callback function that is passed to rewrite_parents. Then
      export rewrite_parents for reuse by the line history browser.
      
      We will use this function in line-log.c.
      Signed-off-by: NBo Yang <struggleyb.nku@gmail.com>
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c7edcae0
    • B
      Refactor parse_loc · 25ed3412
      Bo Yang 提交于
      We want to use the same style of -L n,m argument for 'git log -L' as
      for git-blame.  Refactor the argument parsing of the range arguments
      from builtin/blame.c to the (new) file that will hold the 'git log -L'
      logic.
      
      To accommodate different data structures in blame and log -L, the file
      contents are abstracted away; parse_range_arg takes a callback that it
      uses to get the contents of a line of the (notional) file.
      
      The new test is for a case that made me pause during debugging: the
      'blame -L with invalid end' test was the only one that noticed an
      outright failure to parse the end *at all*.  So make a more explicit
      test for that.
      Signed-off-by: NBo Yang <struggleyb.nku@gmail.com>
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      25ed3412
  6. 28 2月, 2013 6 次提交
  7. 27 2月, 2013 5 次提交
  8. 26 2月, 2013 13 次提交