1
0
mirror of https://github.com/git/git synced 2024-07-05 00:58:49 +00:00
Commit Graph

224 Commits

Author SHA1 Message Date
Shawn O. Pearce
1510fea781 Avoid accessing a slow working copy during diffcore operations.
The Cygwin folks have done a fine job at creating a POSIX layer
on Windows That Just Works(tm).  However it comes with a penalty;
accessing files in the working tree by way of stat/open/mmap can
be slower for diffcore than inflating the data from a blob which
is stored in a packfile.

This performance problem is especially an issue in merge-recursive
when dealing with nearly 7000 added files, as we are loading
each file's content from the working directory to perform rename
detection.  I have literally seen (and sadly watched) paint dry in
less time than it takes for merge-recursive to finish such a merge.
On the other hand this very same merge runs very fast on Solaris.

If Git is compiled with NO_FAST_WORKING_DIRECTORY set then we will
avoid looking at the working directory when the blob in question
is available within a packfile and the caller doesn't need the data
unpacked into a temporary file.

We don't use loose objects as they have the same open/mmap/close
costs as the working directory file access, but have the additional
CPU overhead of needing to inflate the content before use.  So it
is still faster to use the working tree file over the loose object.

If the caller needs the file data unpacked into a temporary file
its likely because they are going to call an external diff program,
passing the file as a parameter.  In this case reusing the working
tree file will be faster as we don't need to inflate the data and
write it out to a temporary file.

The NO_FAST_WORKING_DIRECTORY feature is enabled by default on
Cygwin, as that is the platform which currently appears to benefit
the most from this option.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-15 22:11:19 -08:00
Junio C Hamano
f5c589f1df Merge branch 'jc/numstat'
* jc/numstat:
  diff --numstat: show binary with '-' to match "apply --numstat"
2006-12-13 11:00:32 -08:00
Andy Parkins
a159ca0cb7 Allow subcommand.color and color.subcommand color configuration
While adding colour to the branch command it was pointed out that a
config option like "branch.color" conflicts with the pre-existing
"branch.something" namespace used for specifying default merge urls and
branches.  The suggested solution was to flip the order of the
components to "color.branch", which I did for colourising branch.

This patch does the same thing for
  - git-log (color.diff)
  - git-status (color.status)
  - git-diff (color.diff)
  - pager (color.pager)

I haven't removed the old config options; but they should probably be
deprecated and eventually removed to prevent future namespace
collisions.  I've done this deprecation by changing the documentation
for the config file to match the new names; and adding the "color.XXX"
options to contrib/completion/git-completion.bash.

Unfortunately git-svn reads "diff.color" and "pager.color"; which I
don't like to change unilaterally.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-13 01:47:36 -08:00
Junio C Hamano
bfddbc5e1e diff --numstat: show binary with '-' to match "apply --numstat"
This changes the --numstat output for binary files from "0 0" to
"- -" to match what "apply --numstat" does.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-11 14:17:19 -08:00
Junio C Hamano
65606f3530 Merge branch 'js/diff'
* js/diff:
  Turn on recursive with --summary
2006-10-18 22:09:03 -07:00
Junio C Hamano
74e2abe5b7 diff --numstat
[jc: with documentation from Jakub]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-13 21:37:10 -07:00
Johannes Schindelin
d7014dc081 Turn on recursive with --summary
This makes "git log/diff --summary" imply recursive behaviour,
whose effect is summarized in one test output:

    --- a/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial
    +++ b/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial
    @@ -5,7 +5,7 @@ Date:   Mon Jun 26 00:00:00 2006 +0000

	 Initial

    - create mode 040000 dir
    + create mode 100644 dir/sub
      create mode 100644 file0
      create mode 100644 file2
     $

When a file is created in a subdirectory, we used to say just
the directory name only when that directory also was created,
which did not make sense from two reasons.  It is not any more
significant to create a new file in a new directory than to
create a new file in an existing directory, and even if it were,
reportinging the new directory name without saying the actual
filename is not useful.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-05 15:10:40 -07:00
Junio C Hamano
dd0c367e5e Merge branch 'jc/diff-stat'
* jc/diff-stat:
  diff --stat: ensure at least one '-' for deletions, and one '+' for additions
  diff --stat=width[,name-width]: allow custom diffstat output width.
  diff --stat: color output.
  diff --stat: allow custom diffstat output width.
2006-09-30 21:29:18 -07:00
Junio C Hamano
bc1a580757 git-diff -B output fix.
Geert noticed that complete rewrite diff missed the usual a/ and b/
leading paths.  Pickaxe says it never worked, ever.

Embarrassing.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-29 02:06:24 -07:00
Johannes Schindelin
3ed74e608a diff --stat: ensure at least one '-' for deletions, and one '+' for additions
The number of '-' and '+' is still linear. The idea is that
scaled-length := floor(a * length + b) with the following constraints: if
length == 1, scaled-length == 1, and the combined length of plusses
and minusses should not be larger than the width by a small margin. Thus,

	a + b == 1

and
	a * max_plusses + b + a * max_minusses + b = width + 1

The solution is

	a * x + b = ((width - 1) * (x - 1) + max_change - 1)
		 / (max_change - 1)

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-28 22:32:53 -07:00
Linus Torvalds
5c5b2ea9ab diff --stat=width[,name-width]: allow custom diffstat output width.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-28 22:27:29 -07:00
Junio C Hamano
785f743276 diff --stat: color output.
Under --color option, diffstat shows '+' and '-' in the graph
the same color as added and deleted lines.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-27 02:57:37 -07:00
Junio C Hamano
a2540023dc diff --stat: allow custom diffstat output width.
This adds two parameters to "diff --stat".

 . --stat-width=72 tells that the page should fit on 72-column output.

 . --stat-name-width=30 tells that the filename part is limited
   to 30 columns.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-27 02:55:08 -07:00
Junio C Hamano
448c3ef144 diff.c: second war on whitespace.
This adds DIFF_WHITESPACE color class (default = reverse red) to
colored diff output to let you catch common whitespace errors.

 - trailing whitespaces at the end of line
 - a space followed by a tab in the indent

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-24 00:12:44 -07:00
Junio C Hamano
b467fb0b90 Merge branch 'jk/diff'
* jk/diff:
  wt-status: remove extraneous newline from 'deleted:' output
  git-status: document colorization config options
  Teach runstatus about --untracked
  git-commit.sh: convert run_status to a C builtin
  Move color option parsing out of diff.c and into color.[ch]
  diff: support custom callbacks for output
2006-09-17 18:14:03 -07:00
Jeff King
7c92fe0eaa Move color option parsing out of diff.c and into color.[ch]
The intent is to lib-ify colorizing code so it can be reused.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-08 16:44:10 -07:00
Jeff King
0424558190 diff: support custom callbacks for output
Users can request the DIFF_FORMAT_CALLBACK output format to get a callback
consisting of the whole diff_queue_struct.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-07 15:40:25 -07:00
Junio C Hamano
82793c55e4 diff --binary generates full index on binary files.
... without --full-index.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-07 02:44:41 -07:00
Shawn Pearce
9befac470b Replace uses of strdup with xstrdup.
Like xmalloc and xrealloc xstrdup dies with a useful message if
the native strdup() implementation returns NULL rather than a
valid pointer.

I just tried to use xstrdup in new code and found it to be missing.
However I expected it to be present as xmalloc and xrealloc are
already commonly used throughout the code.

[jc: removed the part that deals with last_XXX, which I am
 finding more and more dubious these days.]

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-02 03:24:37 -07:00
Junio C Hamano
b32d37a3a6 Merge branch 'jc/apply'
* jc/apply:
  git-apply --reject: finishing touches.
  apply --reject: count hunks starting from 1, not 0
  git-apply --verbose
  git-apply --reject: send rejects to .rej files.
  git-apply --reject
  apply --reverse: tie it all together.
  diff.c: make binary patch reversible.
  builtin-apply --reverse: two bugfixes.
2006-08-27 17:51:05 -07:00
Shawn Pearce
e702496e43 Convert memcpy(a,b,20) to hashcpy(a,b).
This abstracts away the size of the hash values when copying them
from memory location to memory location, much as the introduction
of hashcmp abstracted away hash value comparsion.

A few call sites were using char* rather than unsigned char* so
I added the cast rather than open hashcpy to be void*.  This is a
reasonable tradeoff as most call sites already use unsigned char*
and the existing hashcmp is also declared to be unsigned char*.

[jc: Splitted the patch to "master" part, to be followed by a
 patch for merge-recursive.c which is not in "master" yet.

 Fixed the cast in the latter hunk to combine-diff.c which was
 wrong in the original.

 Also converted ones left-over in combine-diff.c, diff-lib.c and
 upload-pack.c ]

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-23 13:53:10 -07:00
David Rientjes
a89fccd281 Do not use memcmp(sha1_1, sha1_2, 20) with hardcoded length.
Introduces global inline:

	hashcmp(const unsigned char *sha1, const unsigned char *sha2)

Uses memcmp for comparison and returns the result based on the length of
the hash name (a future runtime decision).

Acked-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-17 14:23:53 -07:00
Junio C Hamano
d4c452f03b diff.c: make binary patch reversible.
This matches the format previous "git-apply --reverse" update
expects.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-16 21:08:45 -07:00
David Rientjes
96f1e58f52 remove unnecessary initializations
[jc: I needed to hand merge the changes to the updated codebase,
 so the result needs to be checked.]

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-15 21:22:20 -07:00
David Rientjes
0bef57ee44 make inline is_null_sha1 global
Replace sha1 comparisons to null_sha1 with a global inline (which previously an
unused static inline in builtin-apply.c)

[jc: with a fix from Jonas Fonseca.]

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-15 15:06:03 -07:00
David Rientjes
8c0b2bb636 diff.c cleanup
Removes conditional return.

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-14 18:38:07 -07:00
Junio C Hamano
f3c5b39567 Merge branch 'th/diff-extra' 2006-08-12 19:34:41 -07:00
Johannes Schindelin
f59a59e22f Add the --color-words option to the diff options family
With this option, the changed words are shown inline. For example,
if a file containing "This is foo" is changed to "This is bar", the diff
will now show "This is " in plain text, "foo" in red, and "bar" in green.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-10 15:28:57 -07:00
Junio C Hamano
943d5b73e2 allow diff.renamelimit to be set regardless of -M/-C
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-09 14:05:23 -07:00
Junio C Hamano
03b9d560be make --find-copies-harder imply -C
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-09 13:17:19 -07:00
Junio C Hamano
ef677686ef diff.c: do not use pathname comparison to tell renames
The final output from diff used to compare pathnames between
preimage and postimage to tell if the filepair is a rename/copy.
By explicitly marking the filepair created by diffcore_rename(),
the output routine, resolve_rename_copy(), does not have to do
so anymore.  This helps feeding a filepair that has different
pathnames in one and two elements to the diff machinery (most
notably, comparing two blobs).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-03 14:41:53 -07:00
Matthias Lederhofer
aa086eb813 pager: config variable pager.color
enable/disable colored output when the pager is in use

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-31 15:32:24 -07:00
Jeff King
ce43697379 Colorize 'commit' lines in log ui
When paging through the output of git-whatchanged, the color cues help to
visually navigate within a diff. However, it is difficult to notice when a
new commit starts, because the commit and log are shown in the "normal"
color. This patch colorizes the 'commit' line, customizable through
diff.colors.commit and defaulting to yellow.

As a side effect, some of the diff color engine (slot enum, get_color) has
become accessible outside of diff.c.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-24 00:04:41 -07:00
Timo Hirvonen
f5b571fcf7 diff: Support 256 colors
Add support for more than 8 colors.  Colors can be specified as numbers
-1..255.  -1 is same as "normal".

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13 21:53:25 -07:00
Timo Hirvonen
f37399e6b0 diff: Support both attributes and colors
Make it possible to set both colors and a attribute for diff colors.
Background colors are supported too.

Syntax is now:

	[attr] [fg [bg]]
	[fg [bg]] [attr]

Empty value is same as "normal normal", ie use default colors.  The new
syntax is backwards compatible.

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13 21:53:23 -07:00
Shawn Pearce
344c52aee5 Avoid C99 initializers
In a handful places, we use C99 structure and array
initializers, which some compilers do not support.

This can be handy when you are trying to compile GIT on a
Solaris system that has an older C compiler, for example.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-10 00:13:28 -07:00
Junio C Hamano
fc93dbbfc9 Merge branch 'ew/diff'
* ew/diff:
  templates/hooks--update: replace diffstat calls with git diff --stat
  diff: do not use configuration magic at the core-level
  Update diff-options and config documentation.
  diff.c: --no-color to defeat diff.color configuration.
  diff.c: respect diff.renames config option
2006-07-09 23:47:39 -07:00
Junio C Hamano
85fb65ed6e "git -p cmd" to page anywhere
This allows you to say:

	git -p diff v2.6.16-rc5..

and the command pipes the output of any git command to your pager.

[jc: this resurrects a month old RFC patch with improvement
 suggested by Linus to call it --paginate instead of --less.]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-09 03:27:03 -07:00
Junio C Hamano
88f0d5d7d9 Merge branch 'sf/diff' 2006-07-09 00:52:36 -07:00
Junio C Hamano
83ad63cfeb diff: do not use configuration magic at the core-level
The Porcelainish has become so much usable as the UI that there
is not much reason people should be using the core programs by
hand anymore.  At this point we are better off making the
behaviour of the core programs predictable by keeping them
unaffected by the configuration variables.  Otherwise they will
become very hard to use as reliable building blocks.

For example, "git-commit -a" internally uses git-diff-files to
figure out the set of paths that need to be updated in the
index, and we should never allow diff.renames that happens to be
in the configuration to interfere (or slow down the process).

The UI level configuration such as showing renamed diff and
coloring are still honored by the Porcelainish ("git log" family
and "git diff"), but not by the core anymore.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-08 03:11:01 -07:00
Junio C Hamano
a0c2089c1d colored diff: diff.color = auto fix
Even if the standard output is connected to a tty, do not
colorize the diff if we are talking to a dumb terminal when
diff.color configuration variable is set to "auto".

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-07 17:48:02 -07:00
Junio C Hamano
fef88bb013 diff.c: --no-color to defeat diff.color configuration.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-07 12:28:54 -07:00
Eric Wong
b68ea12e30 diff.c: respect diff.renames config option
diff.renames is mentioned several times in the documentation,
but to my surprise it didn't do anything before this patch.

Also add the --no-renames option to override this from the
command-line.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-07 12:28:53 -07:00
Stephan Feder
63ac450119 Teach diff -a as shorthand for --text
Signed-off-by: Stephan Feder <sf@b-i-t.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-07 12:28:04 -07:00
Stephan Feder
6d64ea965b Teach --text option to diff
Add new item text to struct diff_options.
If set then do not try to detect binary files.

Signed-off-by: Stephan Feder <sf@b-i-t.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-07 12:28:04 -07:00
Stephan Feder
c9c95bbc9c Do not drop data from '\0' until eol in patch output
The binary file detection is just a heuristic which can well fail.
Do not produce garbage patches in these cases.

Signed-off-by: Stephan Feder <sf@b-i-t.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-07 03:48:10 -07:00
Junio C Hamano
0c926a3d9c Merge branch 'th/diff'
* th/diff:
  builtin-diff: turn recursive on when defaulting to --patch format.
  t4013: note improvements brought by the new output code.
  t4013: add format-patch tests.
  format-patch: fix diff format option implementation
  combine-diff.c: type sanity.
  t4013 test updates for new output code.
  Fix some more diff options changes.
  Fix diff-tree -s
  log --raw: Don't descend into subdirectories by default
  diff-tree: Use ---\n as a message separator
  Print empty line between raw, stat, summary and patch
  t4013: add more tests around -c and --cc
  whatchanged: Default to DIFF_FORMAT_RAW
  Don't xcalloc() struct diffstat_t
  Add msg_sep to diff_options
  DIFF_FORMAT_RAW is not default anymore
  Set default diff output format after parsing command line
  Make --raw option available for all diff commands
  Merge with_raw, with_stat and summary variables to output_format
  t4013: add tests for diff/log family output options.
2006-07-05 16:31:24 -07:00
Joachim B Haga
12f6c308d5 Make zlib compression level configurable, and change default.
With the change in default, "git add ." on kernel dir is about
twice as fast as before, with only minimal (0.5%) change in
object size. The speed difference is even more noticeable
when committing large files, which is now up to 8 times faster.

The configurability is through setting core.compression = [-1..9]
which maps to the zlib constants; -1 is the default, 0 is no
compression, and 1..9 are various speed/size tradeoffs, 9
being slowest.

Signed-off-by: Joachim B Haga (cjhaga@fys.uio.no)
Acked-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-03 13:55:11 -07:00
Timo Hirvonen
d7de00f7e0 --name-only, --name-status, --check and -s are mutually exclusive
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-01 22:26:00 -07:00
Junio C Hamano
9fdc3bb5c2 diff.c: fix get_patch_id()
The function internally generated diff to get the patch id but
passed a wrong emit flags to the xdiff layer when it did so.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-28 22:49:42 -07:00