1. 06 10月, 2008 1 次提交
    • L
      fix bogus "diff --git" header from "diff --no-index" · 71b989e7
      Linus Torvalds 提交于
      When "git diff --no-index" is given an absolute pathname, it
      would generate a diff header with the absolute path
      prepended by the prefix, like:
      
        diff --git a/dev/null b/foo
      
      Not only is this nonsensical, and not only does it violate
      the description of diffs given in git-diff(1), but it would
      produce broken binary diffs. Unlike text diffs, the binary
      diffs don't contain the filenames anywhere else, and so "git
      apply" relies on this header to figure out the filename.
      
      This patch just refuses to use an invalid name for anything
      visible in the diff.
      
      Now, this fixes the "git diff --no-index --binary a
      /dev/null" kind of case (and we'll end up using "a" as the
      basename), but some other insane cases are impossible to
      handle. If you do
      
      	git diff --no-index --binary a /bin/echo
      
      you'll still get a patch like
      
      	diff --git a/a b/bin/echo
      	old mode 100644
      	new mode 100755
      	index ...
      
      and "git apply" will refuse to apply it for a couple of
      reasons, and the diff is simply bogus.
      
      And that, btw, is no longer a bug, I think. It's impossible
      to know whethe the user meant for the patch to be a rename
      or not. And as such, refusing to apply it because you don't
      know what name you should use is probably _exactly_ the
      right thing to do!
      
      Original problem reported by Imre Deak. Test script and problem
      description by Jeff King.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      71b989e7
  2. 21 9月, 2008 1 次提交
  3. 20 9月, 2008 1 次提交
  4. 19 9月, 2008 3 次提交
    • B
      diff.*.xfuncname which uses "extended" regex's for hunk header selection · 45d9414f
      Brandon Casey 提交于
      Currently, the hunk headers produced by 'diff -p' are customizable by
      setting the diff.*.funcname option in the config file. The 'funcname' option
      takes a basic regular expression. This functionality was designed using the
      GNU regex library which, by default, allows using backslashed versions of
      some extended regular expression operators, even in Basic Regular Expression
      mode. For example, the following characters, when backslashed, are
      interpreted according to the extended regular expression rules: ?, +, and |.
      As such, the builtin funcname patterns were created using some extended
      regular expression operators.
      
      Other platforms which adhere more strictly to the POSIX spec do not
      interpret the backslashed extended RE operators in Basic Regular Expression
      mode. This causes the pattern matching for the builtin funcname patterns to
      fail on those platforms.
      
      Introduce a new option 'xfuncname' which uses extended regular expressions,
      and advertise it _instead_ of funcname. Since most users are on GNU
      platforms, the majority of funcname patterns are created and tested there.
      Advertising only xfuncname should help to avoid the creation of non-portable
      patterns which work with GNU regex but not elsewhere.
      
      Additionally, the extended regular expressions may be less ugly and
      complicated compared to the basic RE since many common special operators do
      not need to be backslashed.
      
      For example, the GNU Basic RE:
      
          ^[ 	]*\\(\\(public\\|static\\).*\\)$
      
      becomes the following Extended RE:
      
          ^[ 	]*((public|static).*)$
      Signed-off-by: NBrandon Casey <casey@nrlssc.navy.mil>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      45d9414f
    • B
      diff.c: associate a flag with each pattern and use it for compiling regex · a013585b
      Brandon Casey 提交于
      This is in preparation for allowing extended regular expression patterns.
      Signed-off-by: NBrandon Casey <casey@nrlssc.navy.mil>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a013585b
    • B
      diff.c: return pattern entry pointer rather than just the hunk header pattern · 45e7ca0f
      Brandon Casey 提交于
      This is in preparation for associating a flag with each pattern which will
      control how the pattern is interpreted. For example, as a basic or extended
      regular expression.
      Signed-off-by: NBrandon Casey <casey@nrlssc.navy.mil>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      45e7ca0f
  5. 07 9月, 2008 2 次提交
    • J
      diff --quiet: make it synonym to --exit-code >/dev/null · df58a827
      Junio C Hamano 提交于
      The point of --quiet was to return the status as early as possible without
      doing any extra processing.  Well behaved scripts, when they expect to run
      many diff operations inside, are supposed to run "update-index --refresh"
      upfront; we do not want them to pay the price of iterating over the index
      and comparing the contents to fix the stat dirtiness, and we avoided most
      of the processing in diffcore_std() when --quiet is in effect.
      
      But scripts that adhere to the good practice won't have to pay any more
      price than the necessary lstat(2) that will report stat cleanliness, as
      long as only -q is given without any fancier diff options.
      
      More importantly, users who do ask for "--quiet -M --filter=D" (in order
      to notice only the deletion, not paths that disappeared only because they
      have been renamed away) deserve to get the result they asked for, even it
      means they have to pay the extra price; the alternative is to get a cheap
      early return that gives a result they did not ask for, which is much
      worse.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      df58a827
    • J
      diff Porcelain: do not disable auto index refreshing on -C -C · 9d865356
      Junio C Hamano 提交于
      When we enabled the automatic refreshing of the index to "diff" Porcelain,
      we disabled it when --find-copies-harder was asked, but there is no good
      reason to do so.  In the following command sequence, the first "diff"
      shows an "empty" diff exposing stat dirtyness, while the second one does
      not.
      
          $ >foo
          $ git add foo
          $ touch foo
          $ git diff -C -C
          $ git diff -C
      
      This fixes the inconsistency.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9d865356
  6. 04 9月, 2008 1 次提交
  7. 31 8月, 2008 1 次提交
    • J
      diff: Help "less" hide ^M from the output · 39280970
      Junio C Hamano 提交于
      When the tracked contents have CRLF line endings, colored diff output
      shows "^M" at the end of output lines, which is distracting, even though
      the pager we use by default ("less") knows to hide them.
      
      The problem is that "less" hides a carriage-return only at the end of the
      line, immediately before a line feed.  The colored diff output does not
      take this into account, and emits four element sequence for each line:
      
         - force this color;
         - the line up to but not including the terminating line feed;
         - reset color
         - line feed.
      
      By including the carriage return at the end of the line in the second
      item, we are breaking the smart our pager has in order not to show "^M".
      This can be fixed by changing the sequence to:
      
         - force this color;
         - the line up to but not including the terminating end-of-line;
         - reset color
         - end-of-line.
      
      where end-of-line is either a single linefeed or a CRLF pair.  When the
      output is not colored, "force this color" and "reset color" sequences are
      both empty, so we won't have this problem with or without this patch.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      39280970
  8. 29 8月, 2008 1 次提交
    • L
      Fix '--dirstat' with cross-directory renaming · 441bca0b
      Linus Torvalds 提交于
      The dirstat code depends on the fact that we always generate diffs with
      the names sorted, since it then just does a single-pass walk-over of the
      sorted list of names and how many changes there were. The sorting means
      that all files are nicely grouped by directory.
      
      That all works fine.
      
      Except when we have rename detection, and suddenly the nicely sorted list
      of pathnames isn't all that sorted at all. And now the single-pass dirstat
      walk gets all confused, and you can get results like this:
      
        [torvalds@nehalem linux]$ git diff --dirstat=2 -M v2.6.27-rc4..v2.6.27-rc5
           3.0% arch/powerpc/configs/
           6.8% arch/arm/configs/
           2.7% arch/powerpc/configs/
           4.2% arch/arm/configs/
           5.6% arch/powerpc/configs/
           8.4% arch/arm/configs/
           5.5% arch/powerpc/configs/
          23.3% arch/arm/configs/
           8.6% arch/powerpc/configs/
           4.0% arch/
           4.4% drivers/usb/musb/
           4.0% drivers/watchdog/
           7.6% drivers/
           3.5% fs/
      
      The trivial fix is to add a sorting pass, fixing it to:
      
        [torvalds@nehalem linux]$ git diff --dirstat=2 -M v2.6.27-rc4..v2.6.27-rc5
          43.0% arch/arm/configs/
          25.5% arch/powerpc/configs/
           5.3% arch/
           4.4% drivers/usb/musb/
           4.0% drivers/watchdog/
           7.6% drivers/
           3.5% fs/
      
      Spot the difference. In case anybody wonders: it's because of a ton of
      renames from {include/asm-blackfin => arch/blackfin/include/asm} that just
      totally messed up the file ordering in between arch/arm and arch/powerpc.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      441bca0b
  9. 21 8月, 2008 1 次提交
    • J
      diff --check: do not get confused by new blank lines in the middle · c35539eb
      Junio C Hamano 提交于
      The code remembered that the last diff output it saw was an empty line,
      and tried to reset that state whenever it sees a context line, a non-blank
      new line, or a new hunk.  However, this codepath asks the underlying diff
      engine to feed diff without any context, and the "just saw an empty line"
      state was not reset if you added a new blank line in the last hunk of your
      patch, even if it is not the last line of the file.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c35539eb
  10. 13 8月, 2008 1 次提交
  11. 12 8月, 2008 1 次提交
  12. 06 8月, 2008 1 次提交
    • L
      diff.renamelimit is a basic diff configuration · 2b6ca6df
      Linus Torvalds 提交于
      The configuration was added as a core option in 3299c6f6 (diff: make
      default rename detection limit configurable., 2005-11-15), but 9ce392f4
      (Move diff.renamelimit out of default configuration., 2005-11-21)
      separated diff-related stuff out of the core.
      
      Up to that point it was Ok.
      
      When we separated the Porcelain options out of the git_diff_config in
      83ad63cf (diff: do not use configuration magic at the core-level,
      2006-07-08), we should have been more careful.
      
      This mistake made diff-tree plumbing and git-show Porcelain to notice
      different set of renames when the user explicitly asked for rename
      detection.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2b6ca6df
  13. 03 8月, 2008 3 次提交
  14. 30 7月, 2008 1 次提交
    • K
      format-patch: Produce better output with --inline or --attach · 6b2fbaaf
      Kevin Ballard 提交于
      This patch makes two small changes to improve the output of --inline
      and --attach.
      
      The first is to write a newline preceding the boundary. This is needed because
      MIME defines the encapsulation boundary as including the preceding CRLF (or in
      this case, just LF), so we should be writing one. Without this, the last
      newline in the pre-diff content is consumed instead.
      
      The second change is to always write the line termination character
      (default: newline) even when using --inline or --attach. This is simply to
      improve the aesthetics of the resulting message. When using --inline an email
      client should render the resulting message identically to the non-inline
      version. And when using --attach this adds a blank line preceding the
      attachment in the email, which is visually attractive.
      Signed-off-by: NKevin Ballard <kevin@sb.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6b2fbaaf
  15. 17 7月, 2008 1 次提交
  16. 06 7月, 2008 1 次提交
  17. 29 6月, 2008 1 次提交
  18. 27 6月, 2008 6 次提交
  19. 17 6月, 2008 2 次提交
    • J
      4afbcab9
    • S
      diff: reset color before printing newline · 06ff64ae
      SZEDER Gábor 提交于
      It worked that way since commit 50f575fc (Tweak diff colors,
      2006-06-22), but commit c1795bb0 (Unify whitespace checking, 2007-12-13)
      changed it.  This patch restores the old behaviour.
      
      Besides Linus' arguments in the log message of 50f575fc, resetting color
      before printing newline is also important to keep 'git add --patch'
      happy.  If the last line(s) of a file are removed, then that hunk will
      end with a colored line.  However, if the newline comes before the color
      reset, then the diff output will have an additional line at the end
      containing only the reset sequence.  This causes trouble in
      git-add--interactive.perl's parse_diff function, because @colored will
      have one more element than @diff, and that last element will contain the
      color reset.  The elements of these arrays will then be copied to @hunk,
      but only as many as the number of elements in @diff.  As a result the
      last color reset is lost and all subsequent terminal output will be
      printed in color.
      Signed-off-by: NSZEDER Gábor <szeder@ira.uka.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      06ff64ae
  20. 15 6月, 2008 1 次提交
    • J
      avoid trailing whitespace in zero-change diffstat lines · 4d9b5359
      Jeff King 提交于
      In some cases, we produce a diffstat line even though no
      lines have changed (e.g., because of an exact rename). In
      this case, there is no +/- "graph" after the number of
      changed lines. However, we output the space separator
      unconditionally, meaning that these lines contained a
      trailing space character.
      
      This isn't a huge problem, but in cleaning up the output we
      are able to eliminate some trailing whitespace from a test
      vector.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4d9b5359
  21. 16 5月, 2008 1 次提交
  22. 15 5月, 2008 1 次提交
  23. 04 5月, 2008 2 次提交
  24. 09 4月, 2008 1 次提交
  25. 14 3月, 2008 1 次提交
  26. 02 3月, 2008 2 次提交
    • J
      diff: make sure work tree side is shown as 0{40} when different · 2b459b48
      Junio C Hamano 提交于
      Ping Yin noticed that "git diff-index --raw" shows 0{40} when work tree
      has submodule difference, but "git diff --raw" didn't correctly do so.
      
      There was a mistake in the diffcore_skip_stat_unmatch() that was meant to
      clean up the stat-only difference for running diff between the index and
      work tree and diff between the tree and the work tree, to cause it re-read
      from the submodule repository HEAD.  When ce_stat_match() says work tree
      is different, we should always say 0{40} on the work tree side.
      
      This patch fixes the issue, and adds tests.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2b459b48
    • J
      Clean up find_unique_abbrev() callers · 2efb3b06
      Junio C Hamano 提交于
      Now find_unique_abbrev() never returns NULL, there is no need for callers
      to prepare for seeing NULL and fall back to giving the full 40-hexdigits.
      
      While we are at it, drop "..." in the "git reset" output that reports the
      location of the new HEAD, between the abbreviated commit object name and
      the one line commit summary.  Because we are always showing the HEAD
      (which cannot be missing!), we never had a case where we show the full 40
      hexdigits that is not followed by three dots, and these three dots were
      stealing 3 columns from the precious horizontal screen real estate out of
      80 that can better be used for the one line commit summary.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2efb3b06
  27. 26 2月, 2008 1 次提交