1. 08 5月, 2017 1 次提交
  2. 31 3月, 2017 1 次提交
    • B
      Rename sha1_array to oid_array · 910650d2
      brian m. carlson 提交于
      Since this structure handles an array of object IDs, rename it to struct
      oid_array.  Also rename the accessor functions and the initialization
      constant.
      
      This commit was produced mechanically by providing non-Documentation
      files to the following Perl one-liners:
      
          perl -pi -E 's/struct sha1_array/struct oid_array/g'
          perl -pi -E 's/\bsha1_array_/oid_array_/g'
          perl -pi -E 's/SHA1_ARRAY_INIT/OID_ARRAY_INIT/g'
      Signed-off-by: Nbrian m. carlson <sandals@crustytoothpaste.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      910650d2
  3. 27 10月, 2016 2 次提交
  4. 25 10月, 2016 2 次提交
    • N
      commit: fix empty commit creation when there's no changes but ita entries · 018ec3c8
      Nguyễn Thái Ngọc Duy 提交于
      If i-t-a entries are present and there is no change between the index
      and HEAD i-t-a entries, index_differs_from() still returns "dirty, new
      entries" (aka, the resulting commit is not empty), but cache-tree will
      skip i-t-a entries and produce the exact same tree of current
      commit.
      
      index_differs_from() is supposed to catch this so we can abort
      git-commit (unless --no-empty is specified). Update it to optionally
      ignore i-t-a entries when doing a diff between the index and HEAD so
      that it would return "no change" in this case and abort commit.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      018ec3c8
    • N
      diff-lib: allow ita entries treated as "not yet exist in index" · 425a28e0
      Nguyễn Thái Ngọc Duy 提交于
      When comparing the index and the working tree to show which paths are
      new, and comparing the tree recorded in the HEAD and the index to see if
      committing the contents recorded in the index would result in an empty
      commit, we would want the former comparison to say "these are new paths"
      and the latter to say "there is no change" for paths that are marked as
      intent-to-add.
      
      We made a similar attempt at d95d728a ("diff-lib.c: adjust position of
      i-t-a entries in diff", 2015-03-16), which redefined the semantics of
      these two comparison modes globally, which was a disaster and had to be
      reverted at 78cc1a54 ("Revert "diff-lib.c: adjust position of i-t-a
      entries in diff"", 2015-06-23).
      
      To make sure we do not repeat the same mistake, introduce a new internal
      diffopt option so that this different semantics can be asked for only by
      callers that ask it, while making sure other unaudited callers will get
      the same comparison result.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      425a28e0
  5. 20 9月, 2016 1 次提交
    • M
      blame: honor the diff heuristic options and config · 5b162879
      Michael Haggerty 提交于
      Teach "git blame" and "git annotate" the --compaction-heuristic and
      --indent-heuristic options that are now supported by "git diff".
      
      Also teach them to honor the `diff.compactionHeuristic` and
      `diff.indentHeuristic` configuration options.
      
      It would be conceivable to introduce separate configuration options for
      "blame" and "annotate"; for example `blame.compactionHeuristic` and
      `blame.indentHeuristic`. But it would be confusing to users if blame
      output is inconsistent with diff output, so it makes more sense for them
      to respect the same configuration.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5b162879
  6. 01 9月, 2016 4 次提交
    • J
      diff: teach diff to display submodule difference with an inline diff · fd47ae6a
      Jacob Keller 提交于
      Teach git-diff and friends a new format for displaying the difference
      of a submodule. The new format is an inline diff of the contents of the
      submodule between the commit range of the update. This allows the user
      to see the actual code change caused by a submodule update.
      
      Add tests for the new format and option.
      Signed-off-by: NJacob Keller <jacob.keller@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fd47ae6a
    • J
      diff: prepare for additional submodule formats · 61cfbc05
      Jacob Keller 提交于
      A future patch will add a new format for displaying the difference of
      a submodule. Make it easier by changing how we store the current
      selected format. Replace the DIFF_OPT flag with an enumeration, as each
      format will be mutually exclusive.
      Signed-off-by: NJacob Keller <jacob.keller@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      61cfbc05
    • J
      graph: add support for --line-prefix on all graph-aware output · 660e113c
      Jacob Keller 提交于
      Add an extension to git-diff and git-log (and any other graph-aware
      displayable output) such that "--line-prefix=<string>" will print the
      additional line-prefix on every line of output.
      
      To make this work, we have to fix a few bugs in the graph API that force
      graph_show_commit_msg to be used only when you have a valid graph.
      Additionally, we extend the default_diff_output_prefix handler to work
      even when no graph is enabled.
      
      This is somewhat of a hack on top of the graph API, but I think it
      should be acceptable here.
      
      This will be used by a future extension of submodule display which
      displays the submodule diff as the actual diff between the pre and post
      commit in the submodule project.
      
      Add some tests for both git-log and git-diff to ensure that the prefix
      is honored correctly.
      Signed-off-by: NJacob Keller <jacob.keller@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      660e113c
    • J
      diff.c: remove output_prefix_length field · cd48dadb
      Junio C Hamano 提交于
      "diff/log --stat" has a logic that determines the display columns
      available for the diffstat part of the output and apportions it for
      pathnames and diffstat graph automatically.
      
      5e71a84a (Add output_prefix_length to diff_options, 2012-04-16)
      added the output_prefix_length field to diff_options structure to
      allow this logic to subtract the display columns used for the
      history graph part from the total "terminal width"; this matters
      when the "git log --graph -p" option is in use.
      
      The field must be set to the number of display columns needed to
      show the output from the output_prefix() callback, which is error
      prone.  As there is only one user of the field, and the user has the
      actual value of the prefix string, let's get rid of the field and
      have the user count the display width itself.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cd48dadb
  7. 30 7月, 2016 1 次提交
  8. 17 3月, 2016 1 次提交
  9. 26 2月, 2016 1 次提交
    • M
      diff: activate diff.renames by default · 5404c116
      Matthieu Moy 提交于
      Rename detection is a very convenient feature, and new users shouldn't
      have to dig in the documentation to benefit from it.
      
      Potential objections to activating rename detection are that it
      sometimes fail, and it is sometimes slow. But rename detection is
      already activated by default in several cases like "git status" and "git
      merge", so activating diff.renames does not fundamentally change the
      situation. When the rename detection fails, it now fails consistently
      between "git diff" and "git status".
      
      This setting does not affect plumbing commands, hence well-written
      scripts will not be affected.
      Signed-off-by: NMatthieu Moy <Matthieu.Moy@imag.fr>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5404c116
  10. 23 2月, 2016 1 次提交
    • J
      diff: clarify textconv interface · a64e6a44
      Jeff King 提交于
      The memory allocation scheme for the textconv interface is a
      bit tricky, and not well documented. It was originally
      designed as an internal part of diff.c (matching
      fill_mmfile), but gradually was made public.
      
      Refactoring it is difficult, but we can at least improve the
      situation by documenting the intended flow and enforcing it
      with an in-code assertion.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a64e6a44
  11. 20 2月, 2016 1 次提交
  12. 22 1月, 2016 2 次提交
  13. 05 1月, 2016 1 次提交
  14. 10 7月, 2015 1 次提交
  15. 28 5月, 2015 1 次提交
  16. 27 5月, 2015 1 次提交
    • J
      diff.c: --ws-error-highlight=<kind> option · b8767f79
      Junio C Hamano 提交于
      Traditionally, we only cared about whitespace breakages introduced
      in new lines.  Some people want to paint whitespace breakages on old
      lines, too.  When they see a whitespace breakage on a new line, they
      can spot the same kind of whitespace breakage on the corresponding
      old line and want to say "Ah, those breakages are there but they
      were inherited from the original, so let's not touch them for now."
      
      Introduce `--ws-error-highlight=<kind>` option, that lets them pass
      a comma separated list of `old`, `new`, and `context` to specify
      what lines to highlight whitespace errors on.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b8767f79
  17. 14 3月, 2015 1 次提交
  18. 08 4月, 2014 1 次提交
    • K
      tree-diff: rework diff_tree() to generate diffs for multiparent cases as well · 72441af7
      Kirill Smelkov 提交于
      Previously diff_tree(), which is now named ll_diff_tree_sha1(), was
      generating diff_filepair(s) for two trees t1 and t2, and that was
      usually used for a commit as t1=HEAD~, and t2=HEAD - i.e. to see changes
      a commit introduces.
      
      In Git, however, we have fundamentally built flexibility in that a
      commit can have many parents - 1 for a plain commit, 2 for a simple merge,
      but also more than 2 for merging several heads at once.
      
      For merges there is a so called combine-diff, which shows diff, a merge
      introduces by itself, omitting changes done by any parent. That works
      through first finding paths, that are different to all parents, and then
      showing generalized diff, with separate columns for +/- for each parent.
      The code lives in combine-diff.c .
      
      There is an impedance mismatch, however, in that a commit could
      generally have any number of parents, and that while diffing trees, we
      divide cases for 2-tree diffs and more-than-2-tree diffs. I mean there
      is no special casing for multiple parents commits in e.g.
      revision-walker .
      
      That impedance mismatch *hurts* *performance* *badly* for generating
      combined diffs - in "combine-diff: optimize combine_diff_path
      sets intersection" I've already removed some slowness from it, but from
      the timings provided there, it could be seen, that combined diffs still
      cost more than an order of magnitude more cpu time, compared to diff for
      usual commits, and that would only be an optimistic estimate, if we take
      into account that for e.g. linux.git there is only one merge for several
      dozens of plain commits.
      
      That slowness comes from the fact that currently, while generating
      combined diff, a lot of time is spent computing diff(commit,commit^2)
      just to only then intersect that huge diff to almost small set of files
      from diff(commit,commit^1).
      
      That's because at present, to compute combine-diff, for first finding
      paths, that "every parent touches", we use the following combine-diff
      property/definition:
      
      D(A,P1...Pn) = D(A,P1) ^ ... ^ D(A,Pn)      (w.r.t. paths)
      
      where
      
      D(A,P1...Pn) is combined diff between commit A, and parents Pi
      
      and
      
      D(A,Pi) is usual two-tree diff Pi..A
      
      So if any of that D(A,Pi) is huge, tracting 1 n-parent combine-diff as n
      1-parent diffs and intersecting results will be slow.
      
      And usually, for linux.git and other topic-based workflows, that
      D(A,P2) is huge, because, if merge-base of A and P2, is several dozens
      of merges (from A, via first parent) below, that D(A,P2) will be diffing
      sum of merges from several subsystems to 1 subsystem.
      
      The solution is to avoid computing n 1-parent diffs, and to find
      changed-to-all-parents paths via scanning A's and all Pi's trees
      simultaneously, at each step comparing their entries, and based on that
      comparison, populate paths result, and deduce we could *skip*
      *recursing* into subdirectories, if at least for 1 parent, sha1 of that
      dir tree is the same as in A. That would save us from doing significant
      amount of needless work.
      
      Such approach is very similar to what diff_tree() does, only there we
      deal with scanning only 2 trees simultaneously, and for n+1 tree, the
      logic is a bit more complex:
      
      D(T,P1...Pn) calculation scheme
      -------------------------------
      
      D(T,P1...Pn) = D(T,P1) ^ ... ^ D(T,Pn)	(regarding resulting paths set)
      
          D(T,Pj)		- diff between T..Pj
          D(T,P1...Pn)	- combined diff from T to parents P1,...,Pn
      
      We start from all trees, which are sorted, and compare their entries in
      lock-step:
      
           T     P1       Pn
           -     -        -
          |t|   |p1|     |pn|
          |-|   |--| ... |--|      imin = argmin(p1...pn)
          | |   |  |     |  |
          |-|   |--|     |--|
          |.|   |. |     |. |
           .     .        .
           .     .        .
      
      at any time there could be 3 cases:
      
          1)  t < p[imin];
          2)  t > p[imin];
          3)  t = p[imin].
      
      Schematic deduction of what every case means, and what to do, follows:
      
      1)  t < p[imin]  ->  ∀j t ∉ Pj  ->  "+t" ∈ D(T,Pj)  ->  D += "+t";  t↓
      
      2)  t > p[imin]
      
          2.1) ∃j: pj > p[imin]  ->  "-p[imin]" ∉ D(T,Pj)  ->  D += ø;  ∀ pi=p[imin]  pi↓
          2.2) ∀i  pi = p[imin]  ->  pi ∉ T  ->  "-pi" ∈ D(T,Pi)  ->  D += "-p[imin]";  ∀i pi↓
      
      3)  t = p[imin]
      
          3.1) ∃j: pj > p[imin]  ->  "+t" ∈ D(T,Pj)  ->  only pi=p[imin] remains to investigate
          3.2) pi = p[imin]  ->  investigate δ(t,pi)
           |
           |
           v
      
          3.1+3.2) looking at δ(t,pi) ∀i: pi=p[imin] - if all != ø  ->
      
                            ⎧δ(t,pi)  - if pi=p[imin]
                   ->  D += ⎨
                            ⎩"+t"     - if pi>p[imin]
      
          in any case t↓  ∀ pi=p[imin]  pi↓
      
      ~
      
      For comparison, here is how diff_tree() works:
      
      D(A,B) calculation scheme
      -------------------------
      
          A     B
          -     -
         |a|   |b|    a < b   ->  a ∉ B   ->   D(A,B) +=  +a    a↓
         |-|   |-|    a > b   ->  b ∉ A   ->   D(A,B) +=  -b    b↓
         | |   | |    a = b   ->  investigate δ(a,b)            a↓ b↓
         |-|   |-|
         |.|   |.|
          .     .
          .     .
      
      ~~~~~~~~
      
      This patch generalizes diff tree-walker to work with arbitrary number of
      parents as described above - i.e. now there is a resulting tree t, and
      some parents trees tp[i] i=[0..nparent). The generalization builds on
      the fact that usual diff
      
      D(A,B)
      
      is by definition the same as combined diff
      
      D(A,[B]),
      
      so if we could rework the code for common case and make it be not slower
      for nparent=1 case, usual diff(t1,t2) generation will not be slower, and
      multiparent diff tree-walker would greatly benefit generating
      combine-diff.
      
      What we do is as follows:
      
      1) diff tree-walker ll_diff_tree_sha1() is internally reworked to be
         a paths generator (new name diff_tree_paths()), with each generated path
         being `struct combine_diff_path` with info for path, new sha1,mode and for
         every parent which sha1,mode it was in it.
      
      2) From that info, we can still generate usual diff queue with
         struct diff_filepairs, via "exporting" generated
         combine_diff_path, if we know we run for nparent=1 case.
         (see emit_diff() which is now named emit_diff_first_parent_only())
      
      3) In order for diff_can_quit_early(), which checks
      
             DIFF_OPT_TST(opt, HAS_CHANGES))
      
         to work, that exporting have to be happening not in bulk, but
         incrementally, one diff path at a time.
      
         For such consumers, there is a new callback in diff_options
         introduced:
      
             ->pathchange(opt, struct combine_diff_path *)
      
         which, if set to !NULL, is called for every generated path.
      
         (see new compat ll_diff_tree_sha1() wrapper around new paths
          generator for setup)
      
      4) The paths generation itself, is reworked from previous
         ll_diff_tree_sha1() code according to "D(A,P1...Pn) calculation
         scheme" provided above:
      
         On the start we allocate [nparent] arrays in place what was
         earlier just for one parent tree.
      
         then we just generalize loops, and comparison according to the
         algorithm.
      
      Some notes(*):
      
      1) alloca(), for small arrays, is used for "runs not slower for
         nparent=1 case than before" goal - if we change it to xmalloc()/free()
         the timings get ~1% worse. For alloca() we use just-introduced
         xalloca/xalloca_free compatibility wrappers, so it should not be a
         portability problem.
      
      2) For every parent tree, we need to keep a tag, whether entry from that
         parent equals to entry from minimal parent. For performance reasons I'm
         keeping that tag in entry's mode field in unused bit - see S_IFXMIN_NEQ.
         Not doing so, we'd need to alloca another [nparent] array, which hurts
         performance.
      
      3) For emitted paths, memory could be reused, if we know the path was
         processed via callback and will not be needed later. We use efficient
         hand-made realloc-style path_appendnew(), that saves us from ~1-1.5%
         of potential additional slowdown.
      
      4) goto(s) are used in several places, as the code executes a little bit
         faster with lowered register pressure.
      
      Also
      
      - we should now check for FIND_COPIES_HARDER not only when two entries
        names are the same, and their hashes are equal, but also for a case,
        when a path was removed from some of all parents having it.
      
        The reason is, if we don't, that path won't be emitted at all (see
        "a > xi" case), and we'll just skip it, and FIND_COPIES_HARDER wants
        all paths - with diff or without - to be emitted, to be later analyzed
        for being copies sources.
      
        The new check is only necessary for nparent >1, as for nparent=1 case
        xmin_eqtotal always =1 =nparent, and a path is always added to diff as
        removal.
      
      ~~~~~~~~
      
      Timings for
      
          # without -c, i.e. testing only nparent=1 case
          `git log --raw --no-abbrev --no-renames`
      
      before and after the patch are as follows:
      
                      navy.git        linux.git v3.10..v3.11
      
          before      0.611s          1.889s
          after       0.619s          1.907s
          slowdown    1.3%            0.9%
      
      This timings show we did no harm to usual diff(tree1,tree2) generation.
      From the table we can see that we actually did ~1% slowdown, but I think
      I've "earned" that 1% in the previous patch ("tree-diff: reuse base
      str(buf) memory on sub-tree recursion", HEAD~~) so for nparent=1 case,
      net timings stays approximately the same.
      
      The output also stayed the same.
      
      (*) If we revert 1)-4) to more usual techniques, for nparent=1 case,
          we'll get ~2-2.5% of additional slowdown, which I've tried to avoid, as
         "do no harm for nparent=1 case" rule.
      
      For linux.git, combined diff will run an order of magnitude faster and
      appropriate timings will be provided in the next commit, as we'll be
      taking advantage of the new diff tree-walker for combined-diff
      generation there.
      
      P.S. and combined diff is not some exotic/for-play-only stuff - for
      example for a program I write to represent Git archives as readonly
      filesystem, there is initial scan with
      
          `git log --reverse --raw --no-abbrev --no-renames -c`
      
      to extract log of what was created/changed when, as a result building a
      map
      
          {}  sha1    ->  in which commit (and date) a content was added
      
      that `-c` means also show combined diff for merges, and without them, if
      a merge is non-trivial (merges changes from two parents with both having
      separate changes to a file), or an evil one, the map will not be full,
      i.e. some valid sha1 would be absent from it.
      
      That case was my initial motivation for combined diffs speedup.
      Signed-off-by: NKirill Smelkov <kirr@mns.spb.ru>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      72441af7
  19. 27 3月, 2014 1 次提交
  20. 25 2月, 2014 1 次提交
  21. 13 12月, 2013 1 次提交
  22. 07 12月, 2013 1 次提交
    • Z
      difftool: display the number of files in the diff queue in the prompt · ee7fb0b1
      Zoltan Klinger 提交于
      When --prompt option is set, git-difftool displays a prompt for each
      modified file to be viewed in an external diff program.  At that
      point, it could be useful to display a counter and the total number
      of files in the diff queue.
      
      Below is the current difftool prompt for the first of 5 modified files:
      
          Viewing: 'diff.c'
          Launch 'vimdiff' [Y/n]:
      
      Consider the modified prompt:
      
          Viewing (1/5): 'diff.c'
          Launch 'vimdiff' [Y/n]:
      
      The current GIT_EXTERNAL_DIFF mechanism does not tell the number of
      paths in the diff queue nor the current counter.  To make this
      "counter/total" info available for GIT_EXTERNAL_DIFF programs
      without breaking existing ones by doing the following:
      
       - Keep track of the number of paths shown so far in diff_options;
      
       - Export two new environment variables from run_external_diff() to
         show the total number of paths (from diff_queue_struct) and the
         current value of the counter (from diff_options); and
      
       - Update git-difftool--helper to use these two environment variables.
      Signed-off-by: NZoltan Klinger <zoltan.klinger@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ee7fb0b1
  23. 01 11月, 2013 1 次提交
  24. 20 7月, 2013 2 次提交
  25. 18 7月, 2013 1 次提交
  26. 16 7月, 2013 2 次提交
  27. 11 5月, 2013 1 次提交
    • J
      diff_opt: track whether flags have been set explicitly · 6c374008
      Junio C Hamano 提交于
      The diff_opt infrastructure sets flags based on defaults and command
      line options.  It is impossible to tell whether a flag has been set
      as a default or on explicit request.  Update the structure so that
      this detection is possible:
      
       * Add an extra "opt->touched_flags" that keeps track of all the
         fields that have been touched by DIFF_OPT_SET and DIFF_OPT_CLR.
      
       * You may continue setting the default values to the flags, like
         commands in the "log" family do in cmd_log_init_defaults(), but
         after you finished setting the defaults, you clear the
         touched_flags field;
      
       * And then you let the usual callchain call diff_opt_parse(),
         allowing the opt->flags be set or unset, while keeping track of
         which bits the user touched;
      
       * There is an optional callback "opt->set_default" that is called
         at the very beginning to let you inspect touched_flags and update
         opt->flags appropriately, before the remainder of the diffcore
         machinery is set up, taking the opt->flags value into account.
      Signed-off-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6c374008
  28. 13 2月, 2013 1 次提交
  29. 17 1月, 2013 1 次提交
  30. 29 10月, 2012 1 次提交
  31. 16 9月, 2012 1 次提交
  32. 04 8月, 2012 1 次提交
    • T
      diff_setup_done(): return void · 28452655
      Thomas Rast 提交于
      diff_setup_done() has historically returned an error code, but lost
      the last nonzero return in 943d5b73 (allow diff.renamelimit to be set
      regardless of -M/-C, 2006-08-09).  The callers were in a pretty
      confused state: some actually checked for the return code, and some
      did not.
      
      Let it return void, and patch all callers to take this into account.
      This conveniently also gets rid of a handful of different(!) error
      messages that could never be triggered anyway.
      
      Note that the function can still die().
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28452655