1. 28 11月, 2012 1 次提交
  2. 18 10月, 2012 1 次提交
    • L
      Fix "git diff --stat" for interesting - but empty - file changes · 74faaa16
      Linus Torvalds 提交于
      The behavior of "git diff --stat" is rather odd for files that have
      zero lines of changes: it will discount them entirely unless they were
      renames.
      
      Which means that the stat output will simply not show files that only
      had "other" changes: they were created or deleted, or their mode was
      changed.
      
      Now, those changes do show up in the summary, but so do renames, so
      the diffstat logic is inconsistent. Why does it show renames with zero
      lines changed, but not mode changes or added files with zero lines
      changed?
      
      So change the logic to not check for "is_renamed", but for
      "is_interesting" instead, where "interesting" is judged to be any
      action but a pure data change (because a pure data change with zero
      data changed really isn't worth showing, if we ever get one in our
      diffpairs).
      
      So if you did
      
         chmod +x Makefile
         git diff --stat
      
      before, it would show empty (" 0 files changed"), with this it shows
      
       Makefile | 0
       1 file changed, 0 insertions(+), 0 deletions(-)
      
      which I think is a more correct diffstat (and then with "--summary" it
      shows *what* the metadata change to Makefile was - this is completely
      consistent with our handling of renamed files).
      
      Side note: the old behavior was *really* odd. With no changes at all,
      "git diff --stat" output was empty. With just a chmod, it said "0
      files changed". No way is our legacy behavior sane.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      74faaa16
  3. 16 9月, 2012 1 次提交
  4. 15 9月, 2012 1 次提交
  5. 06 8月, 2012 1 次提交
    • A
      Fix '\ No newline...' annotation in rewrite diffs · 35e2d03c
      Adam Butcher 提交于
      When a file that ends with an incomplete line is expressed as a
      complete rewrite with the -B option, git diff incorrectly
      appends the incomplete line indicator "\ No newline at end of
      file" after such a line, rather than writing it on a line of its
      own (the output codepath for normal output without -B does not
      have this problem).  Add a LF after the incomplete line before
      writing the "\ No newline ..." out to fix this.
      
      Add a couple of tests to confirm that the indicator comment is
      generated on its own line in both plain diff and rewrite mode.
      Signed-off-by: NAdam Butcher <dev.lists@jessamine.co.uk>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      35e2d03c
  6. 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
  7. 30 7月, 2012 1 次提交
    • J
      diff: do not use null sha1 as a sentinel value · e5450100
      Jeff King 提交于
      The diff code represents paths using the diff_filespec
      struct. This struct has a sha1 to represent the sha1 of the
      content at that path, as well as a sha1_valid member which
      indicates whether its sha1 field is actually useful. If
      sha1_valid is not true, then the filespec represents a
      working tree file (e.g., for the no-index case, or for when
      the index is not up-to-date).
      
      The diff_filespec is only used internally, though. At the
      interfaces to the diff subsystem, callers feed the sha1
      directly, and we create a diff_filespec from it. It's at
      that point that we look at the sha1 and decide whether it is
      valid or not; callers may pass the null sha1 as a sentinel
      value to indicate that it is not.
      
      We should not typically see the null sha1 coming from any
      other source (e.g., in the index itself, or from a tree).
      However, a corrupt tree might have a null sha1, which would
      cause "diff --patch" to accidentally diff the working tree
      version of a file instead of treating it as a blob.
      
      This patch extends the edges of the diff interface to accept
      a "sha1_valid" flag whenever we accept a sha1, and to use
      that flag when creating a filespec. In some cases, this
      means passing the flag through several layers, making the
      code change larger than would be desirable.
      
      One alternative would be to simply die() upon seeing
      corrupted trees with null sha1s. However, this fix more
      directly addresses the problem (while bogus sha1s in a tree
      are probably a bad thing, it is really the sentinel
      confusion sending us down the wrong code path that is what
      makes it devastating). And it means that git is more capable
      of examining and debugging these corrupted trees. For
      example, you can still "diff --raw" such a tree to find out
      when the bogus entry was introduced; you just cannot do a
      "--patch" diff (just as you could not with any other
      corrupted tree, as we do not have any content to diff).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e5450100
  8. 27 7月, 2012 1 次提交
  9. 18 7月, 2012 1 次提交
    • J
      diff: correctly disable external_diff with --no-ext-diff · bd8c1a9b
      Junio C Hamano 提交于
      Upon seeing a type-change filepair, "diff --no-ext-diff" does not
      show the usual "deletion followed by addition" split patch and does
      not run the external diff driver either.
      
      This is because the logic to disable external diff was placed at a
      wrong level in the callchain.  run_diff_cmd() decides to show the
      split patch only when external diff driver is not configured or
      specified via GIT_EXTERNAL_DIFF environment, but this is done before
      checking if --no-ext-diff was given.  To make things worse,
      run_diff_cmd() checks --no-ext-diff and disables the output for such
      a filepair completely, as the callchain below it (e.g. builtin_diff)
      does not want to handle typechange filepairs.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bd8c1a9b
  10. 29 6月, 2012 1 次提交
    • J
      diff-index.c: "git diff" has no need to read blob from the standard input · 4682d852
      Junio C Hamano 提交于
      Only "diff --no-index -" does.  Bolting the logic into the low-level
      function diff_populate_filespec() was a layering violation from day
      one.  Move populate_from_stdin() function out of the generic diff.c
      to its only user, diff-index.c.
      
      Also make sure "-" from the command line stays a special token "read
      from the standard input", even if we later decide to sanitize the
      result from prefix_filename() function in a few obvious ways,
      e.g. removing unnecessary "./" prefix, duplicated slashes "//" in
      the middle, etc.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4682d852
  11. 16 6月, 2012 1 次提交
  12. 02 5月, 2012 2 次提交
  13. 01 5月, 2012 1 次提交
    • Z
      diff --stat: use less columns for change counts · dc801e71
      Zbigniew Jędrzejewski-Szmek 提交于
      Number of columns required for change counts is now computed based on
      the maximum number of changed lines instead of being fixed. This means
      that usually a few more columns will be available for the filenames
      and the graph.
      
      The graph width logic is also modified to include enough space for
      "Bin XXX -> YYY bytes".
      
      If changes to binary files are mixed with changes to text files,
      change counts are padded to take at least three columns. And the other
      way around, if change counts require more than three columns, then
      "Bin"s are padded to align with the change count. This way, the +-
      part starts in the same column as "XXX -> YYY" part for binary files.
      This makes the graph easier to parse visually thanks to the empty
      column. This mimics the layout of diff --stat before this change.
      
      Tests and the tutorial are updated to reflect the new --stat output.
      This means either the removal of extra padding and/or the addition of
      up to three extra characters to truncated filenames. One test is added
      to check the graph alignment when a binary file change and text file
      change of more than 999 lines are committed together.
      Signed-off-by: NZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dc801e71
  14. 19 4月, 2012 1 次提交
  15. 17 4月, 2012 1 次提交
  16. 24 3月, 2012 1 次提交
    • J
      teach diffcore-rename to optionally ignore empty content · 90d43b07
      Jeff King 提交于
      Our rename detection is a heuristic, matching pairs of
      removed and added files with similar or identical content.
      It's unlikely to be wrong when there is actual content to
      compare, and we already take care not to do inexact rename
      detection when there is not enough content to produce good
      results.
      
      However, we always do exact rename detection, even when the
      blob is tiny or empty. It's easy to get false positives with
      an empty blob, simply because it is an obvious content to
      use as a boilerplate (e.g., when telling git that an empty
      directory is worth tracking via an empty .gitignore).
      
      This patch lets callers specify whether or not they are
      interested in using empty files as rename sources and
      destinations. The default is "yes", keeping the original
      behavior. It works by detecting the empty-blob sha1 for
      rename sources and destinations.
      
      One more flexible alternative would be to allow the caller
      to specify a minimum size for a blob to be "interesting" for
      rename detection. But that would catch small boilerplate
      files, not large ones (e.g., if you had the GPL COPYING file
      in many directories).
      
      A better alternative would be to allow a "-rename"
      gitattribute to allow boilerplate files to be marked as
      such. I'll leave the complexity of that solution until such
      time as somebody actually wants it. The complaints we've
      seen so far revolve around empty files, so let's start with
      the simple thing.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      90d43b07
  17. 21 3月, 2012 1 次提交
  18. 15 3月, 2012 2 次提交
  19. 02 3月, 2012 5 次提交
    • J
      diff -p: squelch "diff --git" header for stat-dirty paths · b3f01ff2
      Junio C Hamano 提交于
      The plumbing "diff" commands look at the working tree files without
      refreshing the index themselves for performance reasons (the calling
      script is expected to do that upfront just once, before calling one or
      more of them).  In the early days of git, they showed the "diff --git"
      header before they actually ask the xdiff machinery to produce patches,
      and ended up showing only these headers if the real contents are the same
      and the difference they noticed was only because the stat info cached in
      the index did not match that of the working tree. It was too late for the
      implementation to take the header that it already emitted back.
      
      But 3e97c7c6 (No diff -b/-w output for all-whitespace changes, 2009-11-19)
      introduced necessary logic to keep the meta-information headers in a
      strbuf and delay their output until the xdiff machinery noticed actual
      changes. This was primarily in order to generate patches that ignore
      whitespaces. When operating under "-w" mode, we wouldn't know if the
      header is needed until we actually look at the resulting patch, so it was
      a sensible thing to do, but we did not realize that the same reasoning
      applies to stat-dirty paths.
      
      Later, 296c6bb2 (diff: fix "git show -C -C" output when renaming a binary
      file, 2010-05-26) generalized this machinery and added must_show_header
      toggle.  This is turned on when the header must be shown even when there
      is no patch to be produced, e.g. only the mode was changed, or the path
      was renamed, without changing the contents.  However, when it did so, it
      still kept the special case for the "-w" mode, which meant that the
      plumbing would keep showing these phantom changes.
      
      This corrects this historical inconsistency by allowing the plumbing to
      omit paths that are only stat-dirty from its output in the same way as it
      handles whitespace only changes under "-w" option.
      
      The change in the behaviour can be seen in the updated test.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b3f01ff2
    • Z
      diff --stat: add config option to limit graph width · df44483a
      Zbigniew Jędrzejewski-Szmek 提交于
      Config option diff.statGraphWidth=<width> is equivalent to
      --stat-graph-width=<width>, except that the config option is ignored
      by format-patch.
      
      For the graph-width limiting to be usable, it should happen
      'automatically' once configured, hence the config option.
      Nevertheless, graph width limiting only makes sense when used on a
      wide terminal, so it should not influence the output of format-patch,
      which adheres to the 80-column standard.
      Signed-off-by: NZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      df44483a
    • Z
      diff --stat: enable limiting of the graph part · 969fe57b
      Zbigniew Jędrzejewski-Szmek 提交于
      A new option --stat-graph-width=<width> can be used to limit the width
      of the graph part even is more space is available. Up to <width>
      columns will be used for the graph.
      
      If commits changing a lot of lines are displayed in a wide terminal
      window (200 or more columns), and the +- graph uses the full width,
      the output can be hard to comfortably scan with a horizontal movement
      of human eyes. Messages wrapped to about 80 columns would be
      interspersed with very long +- lines. It makes sense to limit the
      width of the graph part to a fixed value (e.g. 70 columns), even if
      more columns are available.
      Signed-off-by: NZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      969fe57b
    • Z
      diff --stat: use a maximum of 5/8 for the filename part · 1b058bc3
      Zbigniew Jędrzejewski-Szmek 提交于
      The way that available columns are divided between the filename part
      and the graph part is modified to use as many columns as necessary for
      the filenames and the rest for the graph.
      
      If there isn't enough columns to print both the filename and the
      graph, at least 5/8 of available space is devoted to filenames. On a
      standard 80 column terminal, or if not connected to a terminal and
      using the default of 80 columns, this gives the same partition as
      before.
      
      The effect of this change is visible in the patch to the test vector
      in t4052; with a small change with long filename, it stops truncating
      the name part too short, and also allocates a bit more columns to the
      graph for larger changes.
      Signed-off-by: NZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1b058bc3
    • Z
      diff --stat: use the full terminal width · af9fedc1
      Zbigniew Jędrzejewski-Szmek 提交于
      Default to the real terminal width for diff --stat output, instead
      of the hard-coded 80 columns.
      
      Some projects (especially in Java), have long filename paths, with
      nested directories or long individual filenames. When files are
      renamed, the filename part in stat output can be almost useless. If
      the middle part between { and } is long (because the file was moved to
      a completely different directory), then most of the path would be
      truncated.
      
      It makes sense to detect and use the full terminal width and display
      full filenames if possible.
      
      The are commands like diff, show, and log, which can adapt the output
      to the terminal width. There are also commands like format-patch,
      whose output should be independent of the terminal width. Since it is
      safer to use the 80-column default, the real terminal width is only
      used if requested by the calling code by setting diffopts.stat_width=-1.
      Normally this value is 0, and can be set by the user only to a
      non-negative value, so -1 is safe to use internally.
      
      This patch only changes the diff builtin to use the full terminal width.
      Signed-off-by: NZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      af9fedc1
  20. 20 2月, 2012 1 次提交
  21. 15 2月, 2012 1 次提交
    • J
      diff --stat: show bars of same length for paths with same amount of changes · 2eeeef24
      Junio C Hamano 提交于
      When commit 3ed74e60 (diff --stat: ensure at least one '-' for deletions,
      and one '+' for additions, 2006-09-28) improved the output for files with
      tiny modifications, we accidentally broke the logic to ensure that two
      equal sized changes are shown with the bars of the same length, even when
      rounding errors exist.
      
      Compute the length of the graph bars, using the same "non-zero changes is
      shown with at least one column" scaling logic, but by scaling the sum of
      additions and deletions to come up with the total length of the bar (this
      ensures that two equal sized changes result in bars of the same length),
      and then scaling the smaller of the additions or deletions. The other side
      is computed as the difference between the two.
      
      This makes the apportioning between additions and deletions less accurate
      due to rounding errors, but it is much less noticeable than two files with
      the same amount of change showing bars of different length.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2eeeef24
  22. 08 2月, 2012 1 次提交
    • J
      drop odd return value semantics from userdiff_config · 6680a087
      Jeff King 提交于
      When the userdiff_config function was introduced in be58e70d
      (diff: unify external diff and funcname parsing code,
      2008-10-05), it used a return value convention unlike any
      other config callback. Like other callbacks, it used "-1" to
      signal error. But it returned "1" to indicate that it found
      something, and "0" otherwise; other callbacks simply
      returned "0" to indicate that no error occurred.
      
      This distinction was necessary at the time, because the
      userdiff namespace overlapped slightly with the color
      configuration namespace. So "diff.color.foo" could mean "the
      'foo' slot of diff coloring" or "the 'foo' component of the
      "color" userdiff driver". Because the color-parsing code
      would die on an unknown color slot, we needed the userdiff
      code to indicate that it had matched the variable, letting
      us bypass the color-parsing code entirely.
      
      Later, in 8b8e8624 (ignore unknown color configuration,
      2009-12-12), the color-parsing code learned to silently
      ignore unknown slots. This means we no longer need to
      protect userdiff-matched variables from reaching the
      color-parsing code.
      
      We can therefore change the userdiff_config calling
      convention to a more normal one. This drops some code from
      each caller, which is nice. But more importantly, it reduces
      the cognitive load for readers who may wonder why
      userdiff_config is unlike every other config callback.
      
      There's no need to add a new test confirming that this
      works; t4020 already contains a test that sets
      diff.color.external.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6680a087
  23. 04 2月, 2012 1 次提交
  24. 13 1月, 2012 1 次提交
    • T
      word-diff: ignore '\ No newline at eof' marker · c7c2bc0a
      Thomas Rast 提交于
      The word-diff logic accumulates + and - lines until another line type
      appears (normally [ @\]), at which point it generates the word diff.
      This is usually correct, but it breaks when the preimage does not have
      a newline at EOF:
      
        $ printf "%s" "a a a" >a
        $ printf "%s\n" "a ab a" >b
        $ git diff --no-index --word-diff a b
        diff --git 1/a 2/b
        index 9f68e94..6a7c02f 100644
        --- 1/a
        +++ 2/b
        @@ -1 +1 @@
        [-a a a-]
         No newline at end of file
        {+a ab a+}
      
      Because of the order of the lines in a unified diff
      
        @@ -1 +1 @@
        -a a a
        \ No newline at end of file
        +a ab a
      
      the '\' line flushed the buffers, and the - and + lines were never
      matched with each other.
      
      A proper fix would defer such markers until the end of the hunk.
      However, word-diff is inherently whitespace-ignoring, so as a cheap
      fix simply ignore the marker (and hide it from the output).
      
      We use a prefix match for '\ ' to parallel the logic in
      apply.c:parse_fragment().  We currently do not localize this string
      (just accept other variants of it in git-apply), but this should be
      future-proof.
      Noticed-by: NIvan Shirokoff <shirokoff@yandex-team.ru>
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c7c2bc0a
  25. 11 10月, 2011 1 次提交
    • R
      diff: add option to show whole functions as context · 14937c2c
      René Scharfe 提交于
      Add the option -W/--function-context to git diff.  It is similar to
      the same option of git grep and expands the context of change hunks
      so that the whole surrounding function is shown.  This "natural"
      context can allow changes to be understood better.
      
      Note: GNU patch doesn't like diffs generated with the new option;
      it seems to expect context lines to be the same before and after
      changes.  git apply doesn't complain.
      
      This implementation has the same shortcoming as the one in grep,
      namely that there is no way to explicitly find the end of a
      function.  That means that a few lines of extra context are shown,
      right up to the next recognized function begins.  It's already
      useful in its current form, though.
      
      The function get_func_line() in xdiff/xemit.c is extended to work
      forward as well as backward to find post-context as well as
      pre-context.  It returns the position of the first found matching
      line.  The func_line parameter is made optional, as we don't need
      it for -W.
      
      The enhanced function is then used in xdl_emit_diff() to extend
      the context as needed.  If the added context overlaps with the
      next change, it is merged into the current hunk.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      14937c2c
  26. 04 10月, 2011 1 次提交
  27. 23 9月, 2011 1 次提交
    • J
      diff: teach --stat/--numstat to honor -U$num · f01cae91
      Junio C Hamano 提交于
      "git diff -p" piped to external diffstat and "git diff --stat" may see
      different patch text (both are valid and describe the same change
      correctly) when counting the number of added and deleted lines, arriving
      at different results to confuse the users, as --stat/--numstat codepath
      always uses the hardcoded -U0 as the context length.
      
      Make --stat/--numstat codepath to honor the context length the same way
      as the textual patch codepath does to avoid this problem.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f01cae91
  28. 20 8月, 2011 2 次提交
    • J
      diff: don't load color config in plumbing · 3e1dd17a
      Jeff King 提交于
      The diff config callback is split into two functions: one
      which loads "ui" config, and one which loads "basic" config.
      The former chains to the latter, as the diff UI config is a
      superset of the plumbing config.
      
      The color.diff variable is only loaded in the UI config.
      However, the basic config actually chains to
      git_color_default_config, which loads color.ui. This doesn't
      actually cause any bugs, because the plumbing diff code does
      not actually look at the value of color.ui.
      
      However, it is somewhat nonsensical, and it makes it
      difficult to refactor the color code. It probably came about
      because there is no git_color_config to load only color
      config, but rather just git_color_default_config, which
      loads color config and chains to git_default_config.
      
      This patch splits out the color-specific portion of
      git_color_default_config so that the diff UI config can call
      it directly. This is perhaps better explained by the
      chaining of callbacks. Before we had:
      
        git_diff_ui_config
          -> git_diff_basic_config
            -> git_color_default_config
              -> git_default_config
      
      Now we have:
      
        git_diff_ui_config
          -> git_color_config
          -> git_diff_basic_config
            -> git_default_config
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3e1dd17a
    • J
      color: delay auto-color decision until point of use · daa0c3d9
      Jeff King 提交于
      When we read a color value either from a config file or from
      the command line, we use git_config_colorbool to convert it
      from the tristate always/never/auto into a single yes/no
      boolean value.
      
      This has some timing implications with respect to starting
      a pager.
      
      If we start (or decide not to start) the pager before
      checking the colorbool, everything is fine. Either isatty(1)
      will give us the right information, or we will properly
      check for pager_in_use().
      
      However, if we decide to start a pager after we have checked
      the colorbool, things are not so simple. If stdout is a tty,
      then we will have already decided to use color. However, the
      user may also have configured color.pager not to use color
      with the pager. In this case, we need to actually turn off
      color. Unfortunately, the pager code has no idea which color
      variables were turned on (and there are many of them
      throughout the code, and they may even have been manipulated
      after the colorbool selection by something like "--color" on
      the command line).
      
      This bug can be seen any time a pager is started after
      config and command line options are checked. This has
      affected "git diff" since 89d07f75 (diff: don't run pager if
      user asked for a diff style exit code, 2007-08-12). It has
      also affect the log family since 1fda91b5 (Fix 'git log'
      early pager startup error case, 2010-08-24).
      
      This patch splits the notion of parsing a colorbool and
      actually checking the configuration. The "use_color"
      variables now have an additional possible value,
      GIT_COLOR_AUTO. Users of the variable should use the new
      "want_color()" wrapper, which will lazily determine and
      cache the auto-color decision.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      daa0c3d9
  29. 19 8月, 2011 2 次提交
    • J
      git_config_colorbool: refactor stdout_is_tty handling · e269eb79
      Jeff King 提交于
      Usually this function figures out for itself whether stdout
      is a tty. However, it has an extra parameter just to allow
      git-config to override the auto-detection for its
      --get-colorbool option.
      
      Instead of an extra parameter, let's just use a global
      variable. This makes calling easier in the common case, and
      will make refactoring the colorbool code much simpler.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e269eb79
    • J
      diff: refactor COLOR_DIFF from a flag into an int · f1c96261
      Jeff King 提交于
      This lets us store more than just a bit flag for whether we
      want color; we can also store whether we want automatic
      colors. This can be useful for making the automatic-color
      decision closer to the point of use.
      
      This mostly just involves replacing DIFF_OPT_* calls with
      manipulations of the flag. The biggest exception is that
      calls to DIFF_OPT_TST must check for "o->use_color > 0",
      which lets an "unknown" value (i.e., the default) stay at
      "no color". In the previous code, a value of "-1" was not
      propagated at all.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f1c96261
  30. 13 7月, 2011 1 次提交
    • T
      teach --histogram to diff · 8c912eea
      Tay Ray Chuan 提交于
      Port JGit's HistogramDiff algorithm over to C. Rough numbers (TODO) show
      that it is faster than its --patience cousin, as well as the default
      Meyers algorithm.
      
      The implementation has been reworked to use structs and pointers,
      instead of bitmasks, thus doing away with JGit's 2^28 line limit.
      
      We also use xdiff's default hash table implementation (xdl_hash_bits()
      with XDL_HASHLONG()) for convenience.
      Signed-off-by: NTay Ray Chuan <rctay89@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8c912eea
  31. 11 6月, 2011 2 次提交
    • J
      zlib: zlib can only process 4GB at a time · ef49a7a0
      Junio C Hamano 提交于
      The size of objects we read from the repository and data we try to put
      into the repository are represented in "unsigned long", so that on larger
      architectures we can handle objects that weigh more than 4GB.
      
      But the interface defined in zlib.h to communicate with inflate/deflate
      limits avail_in (how many bytes of input are we calling zlib with) and
      avail_out (how many bytes of output from zlib are we ready to accept)
      fields effectively to 4GB by defining their type to be uInt.
      
      In many places in our code, we allocate a large buffer (e.g. mmap'ing a
      large loose object file) and tell zlib its size by assigning the size to
      avail_in field of the stream, but that will truncate the high octets of
      the real size. The worst part of this story is that we often pass around
      z_stream (the state object used by zlib) to keep track of the number of
      used bytes in input/output buffer by inspecting these two fields, which
      practically limits our callchain to the same 4GB limit.
      
      Wrap z_stream in another structure git_zstream that can express avail_in
      and avail_out in unsigned long. For now, just die() when the caller gives
      a size that cannot be given to a single zlib call. In later patches in the
      series, we would make git_inflate() and git_deflate() internally loop to
      give callers an illusion that our "improved" version of zlib interface can
      operate on a buffer larger than 4GB in one go.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ef49a7a0
    • J
      zlib: wrap deflateBound() too · 225a6f10
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      225a6f10