1. 01 9月, 2010 1 次提交
  2. 14 8月, 2010 1 次提交
    • J
      diff --follow: do call diffcore_std() as necessary · 44c48a90
      Junio C Hamano 提交于
      Usually, diff frontends populate the output queue with filepairs without
      any rename information and call diffcore_std() to sort the renames out.
      When --follow is in effect, however, diff-tree family of frontend has a
      hack that looks like this:
      
          diff-tree frontend
          -> diff_tree_sha1()
             . populate diff_queued_diff
             . if --follow is in effect and there is only one change that
               creates the target path, then
             -> try_to_follow_renames()
      	  -> diff_tree_sha1() with no pathspec but with -C
      	  -> diffcore_std() to find renames
      	  . if rename is found, tweak diff_queued_diff and put a
      	    single filepair that records the found rename there
          -> diffcore_std()
             . tweak elements on diff_queued_diff by
             - rename detection
             - path ordering
             - pickaxe filtering
      
      We need to skip parts of the second call to diffcore_std() that is related
      to rename detection, and do so only when try_to_follow_renames() did find
      a rename.  Earlier 1da6175d (Make diffcore_std only can run once before a
      diff_flush, 2010-05-06) tried to deal with this issue incorrectly; it
      unconditionally disabled any second call to diffcore_std().
      
      This hopefully fixes the breakage.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      44c48a90
  3. 12 8月, 2010 1 次提交
    • J
      diff: strip extra "/" when stripping prefix · d8faea9d
      Jakub Narebski 提交于
      There are two ways a user might want to use "diff --relative":
      
        1. For a file in a directory, like "subdir/file", the user
           can use "--relative=subdir/" to strip the directory.
      
        2. To strip part of a filename, like "foo-10", they can
           use "--relative=foo-".
      
      We currently handle both of those situations. However, if the user passes
      "--relative=subdir" (without the trailing slash), we produce inconsistent
      results. For the unified diff format, we collapse the double-slash of
      "a//file" correctly into "a/file". But for other formats (raw, stat,
      name-status), we end up with "/file".
      
      We can do what the user means here and strip the extra "/" (and only a
      slash).  We are not hurting any existing users of (2) above with this
      behavior change because the existing output for this case was nonsensical.
      
      Patch by Jakub, tests and commit message by Jeff King.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d8faea9d
  4. 10 8月, 2010 2 次提交
    • J
      Add the 'diff.ignoreSubmodules' config setting · be4f2b40
      Johannes Schindelin 提交于
      When you have a lot of submodules checked out, the time penalty to check
      for dirty submodules can easily imply a multiplication of the total time
      by the factor 20. This makes the difference between almost instantaneous
      (< 2 seconds) and unbearably slow (> 50 seconds) here, since the disk
      caches are constantly overloaded.
      
      To this end, the submodule.*.ignore config option was introduced, but it
      is per-submodule.
      
      This commit introduces a global config setting to set a default
      (porcelain) value for the --ignore-submodules option, keeping the
      default at 'none'. It can be overridden by the submodule.*.ignore
      setting and by the --ignore-submodules option.
      
      Incidentally, this commit fixes an issue with the overriding logic:
      multiple --ignore-submodules options would not clear the previously
      set flags.
      
      While at it, fix a typo in the documentation for submodule.*.ignore.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      be4f2b40
    • J
      Submodules: Add the new "ignore" config option for diff and status · aee9c7d6
      Jens Lehmann 提交于
      The new "ignore" config option controls the default behavior for "git
      status" and the diff family. It specifies under what circumstances they
      consider submodules as modified and can be set separately for each
      submodule.
      
      The command line option "--ignore-submodules=" has been extended to accept
      the new parameter "none" for both status and diff.
      
      Users that chose submodules to get rid of long work tree scanning times
      might want to set the "dirty" option for those submodules. This brings
      back the pre 1.7.0 behavior, where submodule work trees were never
      scanned for modifications. By using "--ignore-submodules=none" on the
      command line the status and diff commands can be told to do a full scan.
      
      This option can be set to the following values (which have the same name
      and meaning as for the "--ignore-submodules" option of status and diff):
      
      "all": All changes to the submodule will be ignored.
      
      "dirty": Only differences of the commit recorded in the superproject and
      	the submodules HEAD will be considered modifications, all changes
      	to the work tree of the submodule will be ignored. When using this
      	value, the submodule will not be scanned for work tree changes at
      	all, leading to a performance benefit on large submodules.
      
      "untracked": Only untracked files in the submodules work tree are ignored,
      	a changed HEAD and/or modified files in the submodule will mark it
      	as modified.
      
      "none" (which is the default): Either untracked or modified files in a
      	submodules work tree or a difference between the subdmodules HEAD
      	and the commit recorded in the superproject will make it show up
      	as changed. This value is added as a new parameter for the
      	"--ignore-submodules" option of the diff family and "git status"
      	so the user can override the settings in the configuration.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      aee9c7d6
  5. 07 8月, 2010 3 次提交
  6. 02 8月, 2010 1 次提交
  7. 09 7月, 2010 1 次提交
    • B
      diff.c: fix a graph output bug · e13f38a3
      Bo Yang 提交于
      When --graph is in effect, the line-prefix typically has colored graph
      line segments and ends with reset.  The color sequence "set" given to
      this function is for showing the metainfo part of the patch text and
      (1) it should not be applied to the graph lines, and (2) it will be
      reset at the end of line_prefix so it won't be in effect anyway.
      Signed-off-by: NBo Yang <struggleyb.nku@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e13f38a3
  8. 26 6月, 2010 1 次提交
    • J
      Add the option "--ignore-submodules" to "git status" · 46a958b3
      Jens Lehmann 提交于
      In some use cases it is not desirable that "git status" considers
      submodules that only contain untracked content as dirty. This may happen
      e.g. when the submodule is not under the developers control and not all
      build generated files have been added to .gitignore by the upstream
      developers. Using the "untracked" parameter for the "--ignore-submodules"
      option disables checking for untracked content and lets git diff report
      them as changed only when they have new commits or modified content.
      
      Sometimes it is not wanted to have submodules show up as changed when they
      just contain changes to their work tree (this was the behavior before
      1.7.0). An example for that are scripts which just want to check for
      submodule commits while ignoring any changes to the work tree. Also users
      having large submodules known not to change might want to use this option,
      as the - sometimes substantial - time it takes to scan the submodule work
      tree(s) is saved when using the "dirty" parameter.
      
      And if you want to ignore any changes to submodules, you can now do that
      by using this option without parameters or with "all" (when the config
      option status.submodulesummary is set, using "all" will also suppress the
      output of the submodule summary).
      
      A new function handle_ignore_submodules_arg() is introduced to parse this
      option new to "git status" in a single location, as "git diff" already
      knew it.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      46a958b3
  9. 12 6月, 2010 2 次提交
  10. 07 6月, 2010 1 次提交
  11. 01 6月, 2010 5 次提交
    • B
      Make --color-words work well with --graph · 4297c0ae
      Bo Yang 提交于
      '--color-words' algorithm can be described as:
      
        1. collect a the minus/plus lines of a diff hunk, divided into
           minus-lines and plus-lines;
      
        2. break both minus-lines and plus-lines into words and
           place them into two mmfile_t with one word for each line;
      
        3. use xdiff to run diff on the two mmfile_t to get the words level diff;
      
      And for the common parts of the both file, we output the plus side text.
      diff_words->current_plus is used to trace the current position of the plus file
      which printed. diff_words->last_minus is used to trace the last minus word
      printed.
      
      For '--graph' to work with '--color-words', we need to output the graph prefix
      on each line of color words output. Generally, there are two conditions on
      which we should output the prefix.
      
        1. diff_words->last_minus == 0 &&
           diff_words->current_plus == diff_words->plus.text.ptr
      
           that is: the plus text must start as a new line, and if there is no minus
           word printed, a graph prefix must be printed.
      
        2. diff_words->current_plus > diff_words->plus.text.ptr &&
           *(diff_words->current_plus - 1) == '\n'
      
           that is: a graph prefix must be printed following a '\n'
      Signed-off-by: NBo Yang <struggleyb.nku@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4297c0ae
    • B
      Emit a whole line in one go · 2efcc977
      Bo Yang 提交于
      Since the graph prefix will be printed when calling
      emit_line, so the functions should be used to emit a
      complete line out once a time. No one should call
      emit_line to just output some strings instead of a
      complete line.
      Use a strbuf to compose the whole line, and then
      call emit_line to output it once.
      Signed-off-by: NBo Yang <struggleyb.nku@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2efcc977
    • B
      diff.c: Output the text graph padding before each diff line · 7be57610
      Bo Yang 提交于
      Change output from diff with -p/--dirstat/--binary/--numstat/--stat/
      --shortstat/--check/--summary options to align with graph paddings.
      
      Thanks Jeff King <peff@peff.net> for reporting the '--summary' bug and
      his initial patch.
      Signed-off-by: NBo Yang <struggleyb.nku@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7be57610
    • B
      Add a prefix output callback to diff output · a3c158d4
      Bo Yang 提交于
      The callback can be used to add some prefix string to each line of
      diff output.
      Signed-off-by: NBo Yang <struggleyb.nku@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a3c158d4
    • J
      diff.c: Ensure "index $from..$to" line contains unambiguous SHA1s · 3e5a188f
      Johan Herland 提交于
      In the metainfo section of git diffs there's an "index" line providing
      abbreviated (unless --full-index is used) blob SHA1s from the
      pre-/post-images used to generate the diff. These provide hints that
      can be used to reconstruct a 3-way merge when applying the patch
      (see the --3way option to 'git am' for more details).
      
      In order for this to work, however, the blob SHA1s must not be
      abbreviated into ambiguity.
      
      This patch eliminates the possible ambiguity by using find_unique_abbrev()
      to produce the abbreviated SHA1s (instead of blind abbreviation by way of
      "%.*s").
      
      A testcase verifying the fix is also included.
      Signed-off-by: NJohan Herland <johan@herland.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3e5a188f
  12. 20 5月, 2010 1 次提交
    • B
      diff: fix coloring of extended diff headers · 37466447
      Bert Wesarg 提交于
      Coloring the extended headers where done as a whole not per line. less with
      option -R (which is the default from git) does not support this coloring
      mode because of performance reasons. The -r option would be an alternative
      but has problems with lines that are longer than the screen. Therefore
      stick to the idiom to color each line separately. The problem is, that the
      result of ill_metainfo() will also be used as an parameter to an external
      diff driver, so we need to disable coloring in this case.
      
      Because coloring is now done inside fill_metainfo() we can simply add this
      string to the diff header and therefore keep the last newline in the
      extended header. This results also into the fact that the external diff
      driver now gets this last newline too. Which is a change in behavior
      but a good one.
      Signed-off-by: NBert Wesarg <bert.wesarg@googlemail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      37466447
  13. 19 5月, 2010 2 次提交
  14. 08 5月, 2010 2 次提交
  15. 05 5月, 2010 1 次提交
  16. 02 5月, 2010 1 次提交
    • R
      git diff too slow for a file · 582aa00b
      René Scharfe 提交于
      Ever since the xdiff library had been introduced to git, all its callers
      have used the flag XDF_NEED_MINIMAL.  It makes sure that the smallest
      possible diff is produced, but that takes quite some time if there are
      lots of differences that can be expressed in multiple ways.
      
      This flag makes a difference for only 0.1% of the non-merge commits in
      the git repo of Linux, both in terms of diff size and execution time.
      The patches there are mostly nice and small.
      
      SungHyun Nam however reported a case in a different repo where a diff
      took more than 20 times longer to generate with XDF_NEED_MINIMAL than
      without.  Rebasing became really slow.
      
      This patch removes this flag from all callers.  The default of xdiff is
      saner because it has minimal to no impact in the normal case of small
      diffs and doesn't incur that much of a speed penalty for large ones.
      
      A follow-up patch may introduce a command line option to set the flag if
      the user needs it, similar to GNU diff's -d/--minimal.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      582aa00b
  17. 18 4月, 2010 1 次提交
  18. 15 4月, 2010 1 次提交
    • T
      diff: add --word-diff option that generalizes --color-words · 882749a0
      Thomas Rast 提交于
      This teaches the --color-words engine a more general interface that
      supports two new modes:
      
      * --word-diff=plain, inspired by the 'wdiff' utility (most similar to
        'wdiff -n <old> <new>'): uses delimiters [-removed-] and {+added+}
      
      * --word-diff=porcelain, which generates an ad-hoc machine readable
        format:
        - each diff unit is prefixed by [-+ ] and terminated by newline as
          in unified diff
        - newlines in the input are output as a line consisting only of a
          tilde '~'
      
      Both of these formats still support color if it is enabled, using it
      to highlight the differences.  --color-words becomes a synonym for
      --word-diff=color, which is the color-only format.  Also adds some
      compatibility/convenience options.
      
      Thanks to Junio C Hamano and Miles Bader for good ideas.
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      882749a0
  19. 09 4月, 2010 1 次提交
  20. 02 4月, 2010 4 次提交
    • J
      diff: avoid useless filespec population · b3373982
      Jeff King 提交于
      builtin_diff calls fill_mmfile fairly early, which in turn
      calls diff_populate_filespec, which actually retrieves the
      file's blob contents into a buffer. Long ago, this was
      sensible as we would need to look at the blobs eventually.
      
      These days, however, we may not ever want those blobs if we
      end up using a textconv cache, and for large binary files
      (exactly the sort for which you might have a textconv
      cache), just retrieving the objects can be costly.
      
      This patch just pushes the fill_mmfile call a bit later, so
      we can avoid populating the filespec in some cases.  There
      is one thing to note that looks like a bug but isn't. We
      push the fill_mmfile down into the first branch of a
      conditional. It seems like we would need it on the other
      branch, too, but we don't; fill_textconv does it for us (in
      fact, before this, we were just writing over the results of
      the fill_mmfile on that branch).
      
      Here's a timing sample on a commit with 45 changed jpgs and
      avis. The result is fully textconv cached, but we still
      wasted a lot of time just pulling the blobs from storage.
      The total size of the blobs (source and dest) is about
      180M.
      
        [before]
        $ time git show >/dev/null
        real    0m0.352s
        user    0m0.148s
        sys     0m0.200s
      
        [after]
        $ time git show >/dev/null
        real    0m0.009s
        user    0m0.004s
        sys     0m0.004s
      
      And that's on a warm cache. On a cold cache, the "after"
      case is not much worse, but the "before" case has to do an
      extra 180M of I/O.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b3373982
    • J
      diff: cache textconv output · d9bae1a1
      Jeff King 提交于
      Running a textconv filter can take a long time. It's
      particularly bad for a large file which needs to be spooled
      to disk, but even for small files, the fork+exec overhead
      can add up for something like "git log -p".
      
      This patch uses the notes-cache mechanism to keep a fast
      cache of textconv output. Caches are stored in
      refs/notes/textconv/$x, where $x is the userdiff driver
      defined in gitattributes.
      
      Caching is enabled only if diff.$x.cachetextconv is true.
      
      In my test repo, on a commit with 45 jpg and avi files
      changed and a textconv to show their exif tags:
      
        [before]
        $ time git show >/dev/null
        real    0m13.724s
        user    0m12.057s
        sys     0m1.624s
      
        [after, first run]
        $ git config diff.mfo.cachetextconv true
        $ time git show >/dev/null
        real    0m14.252s
        user    0m12.197s
        sys     0m1.800s
      
        [after, subsequent runs]
        $ time git show >/dev/null
        real    0m0.352s
        user    0m0.148s
        sys     0m0.200s
      
      So for a slight (3.8%) cost on the first run, we achieve an
      almost 40x speed up on subsequent runs.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d9bae1a1
    • J
      textconv: refactor calls to run_textconv · 840383b2
      Jeff King 提交于
      This patch adds a fill_textconv wrapper, which centralizes
      some minor logic like error checking and handling the case
      of no-textconv.
      
      In addition to dropping the number of lines, this will make
      it easier in future patches to handle multiple types of
      textconv.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      840383b2
    • J
      fix textconv leak in emit_rewrite_diff · b76c056b
      Jeff King 提交于
      We correctly free() for the normal diff case, but leak for
      rewrite diffs.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b76c056b
  21. 31 3月, 2010 1 次提交
  22. 25 3月, 2010 1 次提交
  23. 13 3月, 2010 2 次提交
    • J
      git status: Fix false positive "new commits" output for dirty submodules · 85adbf2f
      Jens Lehmann 提交于
      Testing if the output "new commits" should appear in the long format of
      "git status" is done by comparing the hashes of the diffpair. This always
      resulted in printing "new commits" for submodules that contained untracked
      or modified content, even if they did not contain new commits. The reason
      was that match_stat_with_submodule() did set the "changed" flag for dirty
      submodules, resulting in two->sha1 being set to the null_sha1 at the call
      sites, which indicates that new commits are present. This is changed so
      that when no new commits are present, the same object names are in the
      sha1 field for both sides of the filepair, and the working tree side will
      have the "dirty_submodule" flag set when appropriate. For a submodule to
      be seen as modified even when it just has a dirty work tree, some
      conditions had to be extended to also check for the "dirty_submodule"
      flag.
      
      Unfortunately the test case that should have found this bug had been
      changed incorrectly too. It is fixed and extended to test for other
      combinations too.
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      85adbf2f
    • J
      Refactor dirty submodule detection in diff-lib.c · ae6d5c1b
      Jens Lehmann 提交于
      Moving duplicated code into the new function match_stat_with_submodule().
      Replacing the implicit activation of detailed checks for the dirtiness of
      submodules when DIFF_FORMAT_PATCH was selected with explicitly setting
      the recently added DIFF_OPT_DIRTY_SUBMODULES option in diff_setup_done().
      Signed-off-by: NJens Lehmann <Jens.Lehmann@web.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ae6d5c1b
  24. 19 2月, 2010 1 次提交
    • M
      Add an optional argument for --color options · 73e9da01
      Mark Lodato 提交于
      Make git-branch, git-show-branch, git-grep, and all the diff-based
      programs accept an optional argument <when> for --color.  The argument
      is a colorbool: "always", "never", or "auto".  If no argument is given,
      "always" is used;  --no-color is an alias for --color=never.  This makes
      the command-line interface consistent with other GNU tools, such as `ls'
      and `grep', and with the git-config color options.  Note that, without
      an argument, --color and --no-color work exactly as before.
      
      To implement this, two internal changes were made:
      
      1. Allow the first argument of git_config_colorbool() to be NULL,
         in which case it returns -1 if the argument isn't "always", "never",
         or "auto".
      
      2. Add OPT_COLOR_FLAG(), OPT__COLOR(), and parse_opt_color_flag_cb()
         to the option parsing library.  The callback uses
         git_config_colorbool(), so color.h is now a dependency
         of parse-options.c.
      Signed-off-by: NMark Lodato <lodatom@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      73e9da01
  25. 16 2月, 2010 2 次提交