1. 02 3月, 2012 1 次提交
    • 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
  2. 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
  3. 04 2月, 2012 1 次提交
  4. 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
  5. 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
  6. 04 10月, 2011 1 次提交
  7. 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
  8. 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
  9. 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
  10. 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
  11. 11 6月, 2011 3 次提交
    • 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
    • J
      zlib: wrap deflate side of the API · 55bb5c91
      Junio C Hamano 提交于
      Wrap deflateInit, deflate, and deflateEnd for everybody, and the sole use
      of deflateInit2 in remote-curl.c to tell the library to use gzip header
      and trailer in git_deflate_init_gzip().
      
      There is only one caller that cares about the status from deflateEnd().
      Introduce git_deflate_end_gently() to let that sole caller retrieve the
      status and act on it (i.e. die) for now, but we would probably want to
      make inflate_end/deflate_end die when they ran out of memory and get
      rid of the _gently() kind.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      55bb5c91
  12. 01 6月, 2011 1 次提交
    • J
      diff: futureproof "stop feeding the backend early" logic · 28b9264d
      Junio C Hamano 提交于
      Refactor the "do not stop feeding the backend early" logic into a small
      helper function and use it in both run_diff_files() and diff_tree() that
      has the stop-early optimization. We may later add other types of diffcore
      transformation that require to look at the whole result like diff-filter
      does, and having the logic in a single place is essential for longer term
      maintainability.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28b9264d
  13. 28 5月, 2011 3 次提交
  14. 24 5月, 2011 1 次提交
    • J
      refactor get_textconv to not require diff_filespec · 3813e690
      Jeff King 提交于
      This function actually does two things:
      
        1. Load the userdiff driver for the filespec.
      
        2. Decide whether the driver has a textconv component, and
           initialize the textconv cache if applicable.
      
      Only part (1) requires the filespec object, and some callers
      may not have a filespec at all. So let's split them it into
      two functions, and put part (2) with the userdiff code,
      which is a better fit.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3813e690
  15. 21 5月, 2011 1 次提交
    • J
      do not read beyond end of malloc'd buffer · 42536dd9
      Jim Meyering 提交于
      With diff.suppress-blank-empty=true, "git diff --word-diff" would
      output data that had been read from uninitialized heap memory.
      The problem was that fn_out_consume did not account for the
      possibility of a line with length 1, i.e., the empty context line
      that diff.suppress-blank-empty=true converts from " \n" to "\n".
      Since it assumed there would always be a prefix character (the space),
      it decremented "len" unconditionally, thus passing len=0 to emit_line,
      which would then blindly call emit_line_0 with len=-1 which would
      pass that value on to fwrite as SIZE_MAX.  Boom.
      Signed-off-by: NJim Meyering <meyering@redhat.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      42536dd9
  16. 30 4月, 2011 7 次提交
    • J
      7478ac57
    • J
      Improve error handling when parsing dirstat parameters · 51670fc8
      Johan Herland 提交于
      When encountering errors or unknown tokens while parsing parameters to the
      --dirstat option, it makes sense to die() with an error message informing
      the user of which parameter did not make sense. However, when parsing the
      diff.dirstat config variable, we cannot simply die(), but should instead
      (after warning the user) ignore the erroneous or unrecognized parameter.
      After all, future Git versions might add more dirstat parameters, and
      using two different Git versions on the same repo should not cripple the
      older Git version just because of a parameter that is only understood by
      a more recent Git version.
      
      This patch fixes the issue by refactoring the dirstat parameter parsing
      so that parse_dirstat_params() keeps on parsing parameters, even if an
      earlier parameter was not recognized. When parsing has finished, it returns
      zero if all parameters were successfully parsed, and non-zero if one or
      more parameters were not recognized (with appropriate error messages
      appended to the 'errmsg' argument).
      
      The parse_dirstat_params() callers then decide (based on the return value
      from parse_dirstat_params()) whether to warn and ignore (in case of
      diff.dirstat), or to warn and die (in case of --dirstat).
      
      The patch also adds a couple of tests verifying the correct behavior of
      --dirstat and diff.dirstat in the face of unknown (possibly future) dirstat
      parameters.
      Suggested-by: NJunio C Hamano <gitster@pobox.com>
      Improved-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      51670fc8
    • J
      New --dirstat=lines mode, doing dirstat analysis based on diffstat · 1c57a627
      Johan Herland 提交于
      This patch adds an alternative implementation of show_dirstat(), called
      show_dirstat_by_line(), which uses the more expensive diffstat analysis
      (as opposed to show_dirstat()'s own (relatively inexpensive) analysis)
      to derive the numbers from which the --dirstat output is computed.
      
      The alternative implementation is controlled by the new "lines" parameter
      to the --dirstat option (or the diff.dirstat config variable).
      
      For binary files, the diffstat analysis counts bytes instead of lines,
      so to prevent binary files from dominating the dirstat results, the
      byte counts for binary files are divided by 64 before being compared to
      their textual/line-based counterparts. This is a stupid and ugly - but
      very cheap - heuristic.
      
      In linux-2.6.git, running the three different --dirstat modes:
      
        time git diff v2.6.20..v2.6.30 --dirstat=changes > /dev/null
      vs.
        time git diff v2.6.20..v2.6.30 --dirstat=lines > /dev/null
      vs.
        time git diff v2.6.20..v2.6.30 --dirstat=files > /dev/null
      
      yields the following average runtimes on my machine:
      
       - "changes" (default): ~6.0 s
       - "lines":             ~9.6 s
       - "files":             ~0.1 s
      
      So, as expected, there's a considerable performance hit (~60%) by going
      through the full diffstat analysis as compared to the default "changes"
      analysis (obviously, "files" is much faster than both). As such, the
      "lines" mode is probably only useful if you really need the --dirstat
      numbers to be consistent with the numbers returned from the other
      --*stat options.
      
      The patch also includes documentation and tests for the new dirstat mode.
      Improved-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1c57a627
    • J
      Allow specifying --dirstat cut-off percentage as a floating point number · 712d2c7d
      Johan Herland 提交于
      Only the first digit after the decimal point is kept, as the dirstat
      calculations all happen in permille.
      
      Selftests verifying floating-point percentage input has been added.
      Improved-by: NJunio C Hamano <gitster@pobox.com>
      Improved-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      712d2c7d
    • J
      Add config variable for specifying default --dirstat behavior · 2d174951
      Johan Herland 提交于
      The new diff.dirstat config variable takes the same arguments as
      '--dirstat=<args>', and specifies the default arguments for --dirstat.
      The config is obviously overridden by --dirstat arguments passed on the
      command line.
      
      When not specified, the --dirstat defaults are 'changes,noncumulative,3'.
      
      The patch also adds several tests verifying the interaction between the
      diff.dirstat config variable, and the --dirstat command line option.
      Improved-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2d174951
    • J
      Refactor --dirstat parsing; deprecate --cumulative and --dirstat-by-file · 333f3fb0
      Johan Herland 提交于
      Instead of having multiple interconnected dirstat-related options, teach
      the --dirstat option itself to accept all behavior modifiers as parameters.
      
       - Preserve the current --dirstat=<limit> (where <limit> is an integer
         specifying a cut-off percentage)
       - Add --dirstat=cumulative, replacing --cumulative
       - Add --dirstat=files, replacing --dirstat-by-file
       - Also add --dirstat=changes and --dirstat=noncumulative for specifying the
         current default behavior. These allow the user to reset other --dirstat
         parameters (e.g. 'cumulative' and 'files') occuring earlier on the
         command line.
      
      The deprecated options (--cumulative and --dirstat-by-file) are still
      functional, although they have been removed from the documentation.
      
      Allow multiple parameters to be separated by commas, e.g.:
        --dirstat=files,10,cumulative
      
      Update the documentation accordingly, and add testcases verifying the
      behavior of the new syntax.
      Improved-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      333f3fb0
    • J
      Make --dirstat=0 output directories that contribute < 0.1% of changes · 58a8756a
      Johan Herland 提交于
      The expected output from --dirstat=0, is to include any directory with
      changes, even if those changes contribute a minuscule portion of the total
      changes. However, currently, directories that contribute less than 0.1% are
      not included, since their 'permille' value is 0, and there is an
      'if (permille)' check in gather_dirstat() that causes them to be ignored.
      
      This test is obviously intended to exclude directories that contribute no
      changes whatsoever, but in this case, it hits too broadly. The correct
      check is against 'this_dir' from which the permille is calculated. Only if
      this value is 0 does the directory truly contribute no changes, and should
      be skipped from the output.
      
      This patches fixes this issue, and updates corresponding testcases to
      expect the new behvaior.
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      58a8756a
  17. 24 4月, 2011 2 次提交
  18. 13 4月, 2011 1 次提交
  19. 12 4月, 2011 2 次提交
    • J
      Teach --dirstat not to completely ignore rearranged lines within a file · 2ff3a803
      Johan Herland 提交于
      Currently, the --dirstat analysis ignores when lines within a file are
      rearranged, because the "damage" calculated by show_dirstat() is 0.
      However, if the object name has changed, we already know that there is
      some damage, and it is unintuitive to claim there is _no_ damage.
      
      Teach show_dirstat() to assign a minimum amount of damage (== 1) to
      entries for which the analysis otherwise yields zero damage, to still
      represent that these files are changed, instead of saying that there
      is no change.
      
      Also, skip --dirstat analysis when the object names are the same (e.g. for
      a pure file rename).
      Signed-off-by: NJohan Herland <johan@herland.net>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2ff3a803
    • J
      --dirstat-by-file: Make it faster and more correct · 0133dab7
      Johan Herland 提交于
      Currently, when using --dirstat-by-file, it first does the full --dirstat
      analysis (using diffcore_count_changes()), and then resets 'damage' to 1,
      if any damage was found by diffcore_count_changes().
      
      But --dirstat-by-file is not interested in the file damage per se. It only
      cares if the file changed at all. In that sense it only cares if the blob
      object for a file has changed. We therefore only need to compare the
      object names of each file pair in the diff queue and we can skip the
      entire --dirstat analysis and simply set 'damage' to 1 for each entry
      where the object name has changed.
      
      This makes --dirstat-by-file faster, and also bypasses --dirstat's practice
      of ignoring rearranged lines within a file.
      
      The patch also contains an added testcase verifying that --dirstat-by-file
      now detects changes that only rearrange lines within a file.
      Signed-off-by: NJohan Herland <johan@herland.net>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0133dab7
  20. 03 4月, 2011 1 次提交
    • J
      git diff -D: omit the preimage of deletes · 467ddc14
      Junio C Hamano 提交于
      When reviewing a patch while concentrating primarily on the text after
      then change, wading through pages of deleted text involves a cognitive
      burden.
      
      Introduce the -D option that omits the preimage text from the patch output
      for deleted files.  When used with -B (represent total rewrite as a single
      wholesale deletion followed by a single wholesale addition), the preimage
      text is also omitted.
      
      To prevent such a patch from being applied by mistake, the output is
      designed not to be usable by "git apply" (or GNU "patch"); it is strictly
      for human consumption.
      
      It of course is possible to "apply" such a patch by hand, as a human can
      read the intention out of such a patch.  It however is impossible to apply
      such a patch even manually in reverse, as the whole point of this option
      is to omit the information necessary to do so from the output.
      
      Initial request by Mart Sõmermaa, documentation and tests helped by
      Michael J Gruber.
      Signed-off-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      467ddc14
  21. 23 3月, 2011 3 次提交
    • J
      diffcore-rename: fall back to -C when -C -C busts the rename limit · f31027c9
      Junio C Hamano 提交于
      When there are too many paths in the project, the number of rename source
      candidates "git diff -C -C" finds will exceed the rename detection limit,
      and no inexact rename detection is performed.  We however could fall back
      to "git diff -C" if the number of modified paths is sufficiently small.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f31027c9
    • J
      Remove unused variables · c0aa335c
      Johannes Schindelin 提交于
      Noticed by gcc 4.6.0.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c0aa335c
    • S
      Fix sparse warnings · c2e86add
      Stephen Boyd 提交于
      Fix warnings from 'make check'.
      
       - These files don't include 'builtin.h' causing sparse to complain that
         cmd_* isn't declared:
      
         builtin/clone.c:364, builtin/fetch-pack.c:797,
         builtin/fmt-merge-msg.c:34, builtin/hash-object.c:78,
         builtin/merge-index.c:69, builtin/merge-recursive.c:22
         builtin/merge-tree.c:341, builtin/mktag.c:156, builtin/notes.c:426
         builtin/notes.c:822, builtin/pack-redundant.c:596,
         builtin/pack-refs.c:10, builtin/patch-id.c:60, builtin/patch-id.c:149,
         builtin/remote.c:1512, builtin/remote-ext.c:240,
         builtin/remote-fd.c:53, builtin/reset.c:236, builtin/send-pack.c:384,
         builtin/unpack-file.c:25, builtin/var.c:75
      
       - These files have symbols which should be marked static since they're
         only file scope:
      
         submodule.c:12, diff.c:631, replace_object.c:92, submodule.c:13,
         submodule.c:14, trace.c:78, transport.c:195, transport-helper.c:79,
         unpack-trees.c:19, url.c:3, url.c:18, url.c:104, url.c:117, url.c:123,
         url.c:129, url.c:136, thread-utils.c:21, thread-utils.c:48
      
       - These files redeclare symbols to be different types:
      
         builtin/index-pack.c:210, parse-options.c:564, parse-options.c:571,
         usage.c:49, usage.c:58, usage.c:63, usage.c:72
      
       - These files use a literal integer 0 when they really should use a NULL
         pointer:
      
         daemon.c:663, fast-import.c:2942, imap-send.c:1072, notes-merge.c:362
      
      While we're in the area, clean up some unused #includes in builtin files
      (mostly exec_cmd.h).
      Signed-off-by: NStephen Boyd <bebarino@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c2e86add
  22. 17 3月, 2011 1 次提交
    • J
      standardize brace placement in struct definitions · 9cba13ca
      Jonathan Nieder 提交于
      In a struct definitions, unlike functions, the prevailing style is for
      the opening brace to go on the same line as the struct name, like so:
      
       struct foo {
      	int bar;
      	char *baz;
       };
      
      Indeed, grepping for 'struct [a-z_]* {$' yields about 5 times as many
      matches as 'struct [a-z_]*$'.
      
      Linus sayeth:
      
       Heretic people all over the world have claimed that this inconsistency
       is ...  well ...  inconsistent, but all right-thinking people know that
       (a) K&R are _right_ and (b) K&R are right.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9cba13ca
  23. 23 2月, 2011 2 次提交
    • J
      diff: don't retrieve binary blobs for diffstat · abb371a1
      Jeff King 提交于
      We only need the size, which is much cheaper to get,
      especially if it is a big binary file.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      abb371a1
    • J
      diff: handle diffstat of rewritten binary files · ded0abc7
      Jeff King 提交于
      The logic in builtin_diffstat assumes that a
      complete_rewrite pair should have its lines counted. This is
      nonsensical for binary files and leads to confusing things
      like:
      
        $ git diff --stat --summary HEAD^ HEAD
         foo.rand |  Bin 4096 -> 4096 bytes
         1 files changed, 0 insertions(+), 0 deletions(-)
      
        $ git diff --stat --summary -B HEAD^ HEAD
         foo.rand |   34 +++++++++++++++-------------------
         1 files changed, 15 insertions(+), 19 deletions(-)
         rewrite foo.rand (100%)
      
      So let's reorder the function to handle binary files first
      (which from diffstat's perspective look like complete
      rewrites anyway), then rewrites, then actual diffstats.
      
      There are two bonus prizes to this reorder:
      
        1. It gets rid of a now-superfluous goto.
      
        2. The binary case is at the top, which means we can
           further optimize it in the next patch.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ded0abc7