summaryrefslogtreecommitdiff
path: root/diff.c
AgeCommit message (Collapse)Author
2006-08-03diff.c: do not use pathname comparison to tell renamesJunio C Hamano
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-07-31pager: config variable pager.colorMatthias Lederhofer
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-24Colorize 'commit' lines in log uiJeff King
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-14diff: Support 256 colorsTimo Hirvonen
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-14diff: Support both attributes and colorsTimo Hirvonen
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-10Avoid C99 initializersShawn Pearce
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-10Merge branch 'ew/diff'Junio C Hamano
* 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"git -p cmd" to page anywhereJunio C Hamano
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-09Merge branch 'sf/diff'Junio C Hamano
2006-07-08diff: do not use configuration magic at the core-levelJunio C Hamano
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-08colored diff: diff.color = auto fixJunio C Hamano
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-07diff.c: --no-color to defeat diff.color configuration.Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-07diff.c: respect diff.renames config optionEric Wong
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-07Teach diff -a as shorthand for --textStephan Feder
Signed-off-by: Stephan Feder <sf@b-i-t.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-07Teach --text option to diffStephan Feder
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-07Do not drop data from '\0' until eol in patch outputStephan Feder
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-05Merge branch 'th/diff'Junio C Hamano
* 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-03Make zlib compression level configurable, and change default.Joachim B Haga
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-06-29diff.c: fix get_patch_id()Junio C Hamano
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-27Fix some more diff options changes.Junio C Hamano
This fixes various problems in the new diff options code. - Fix --cc/-c --patch; it showed two-tree diff used internally. - Use "---\n" only where it matters -- that is, use it immediately after the commit log text when we show a commit log and something else before the patch text. - Do not output spurious extra "\n"; have an extra newline after the commit log text always when we have diff output and we are not doing oneline. - When running a pickaxe you need to go recursive. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-27Fix diff-tree -sTimo Hirvonen
setup_revisions() calls diff_setup_done() before we can set default value for output_format. Don't convert DIFF_FORMAT_NO_OUTPUT to 0 in diff_setup_done(), it is useless and makes diff-tree believe no diff format parameters were given and thus lets it reset output_format to DIFF_FORMAT_RAW. Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-27Print empty line between raw, stat, summary and patchTimo Hirvonen
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-26Don't xcalloc() struct diffstat_tTimo Hirvonen
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-26Add msg_sep to diff_optionsTimo Hirvonen
Add msg_sep variable to struct diff_options. msg_sep is printed after commit message. Default is "\n", format-patch sets it to "---\n". This also removes the second argument from show_log() because all callers derived it from the first argument: show_log(rev, rev->loginfo, ... Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-26Set default diff output format after parsing command lineTimo Hirvonen
Initialize output_format to 0 instead of DIFF_FORMAT_RAW so that we can see later if any command line options changed it. Default value is set only if output format was not specified. Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-26Make --raw option available for all diff commandsTimo Hirvonen
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-26Merge with_raw, with_stat and summary variables to output_formatTimo Hirvonen
DIFF_FORMAT_* are now bit-flags instead of enumerated values. Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-26add diff_flush_patch_id() to calculate the patch idJohannes Schindelin
Call it like this: unsigned char id[20]; if (diff_flush_patch_id(diff_options, id)) printf("And the patch id is: %s\n", sha1_to_hex(id)); Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-26Merge branch 'jc/diff'Junio C Hamano
* jc/diff: diff --color: use $GIT_DIR/config
2006-06-26Merge branch 'js/diff'Junio C Hamano
* js/diff: Teach diff about -b and -w flags
2006-06-25diff --color: use $GIT_DIR/configJunio C Hamano
This lets you use something like this in your $GIT_DIR/config file. [diff] color = auto [diff.color] new = blue old = yellow frag = reverse When diff.color is set to "auto", colored diff is enabled when the standard output is the terminal. Other choices are "always", and "never". Usual boolean true/false can also be used. The colormap entries can specify colors for the following slots: plain - lines that appear in both old and new file (context) meta - diff --git header and extended git diff headers frag - @@ -n,m +l,k @@ lines (hunk header) old - lines deleted from old file new - lines added to new file The following color names can be used: normal, bold, dim, l, blink, reverse, reset, black, red, green, yellow, blue, magenta, cyan, white Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-25Clean up diff.cTimo Hirvonen
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-24diff --color: use reset sequence when we mean reset.Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-24Teach diff about -b and -w flagsJohannes Schindelin
This adds -b (--ignore-space-change) and -w (--ignore-all-space) flags to diff. The main part of the patch is teaching libxdiff about it. [jc: renamed xdl_line_match() to xdl_recmatch() since the former is used for different purposes in xpatchi.c which is in the parts of the upstream source we do not use.] Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-22Tweak diff colorsLinus Torvalds
This patch does: - always reset the color _before_ printing out the newline. This is actually important. You (and Johannes) didn't see it, because it only matters if you set the background, but if you don't do this, you get some random and funky behaviour if you pick a color with a non-default background (which still potentially has problems with tabs etc, but less so). - allow people to have a different color for the "file headers" (DIFF_METAINFO) and for the "fragment header" (DIFF_FRAGINFO). Also, make a difference between "normal color" and "reset colors" - default to red/green for old/new lines. That's the norm, I'd think. - instead of that eye-popping (and eye-ball-with-a-fondue-fork-popping) purple color for metadata, use bold-face for file headers, and cyan for the frag headers. I actually prefer the "gray background" for that, but it only works well in xterms, so COLOR_CYAN it is.. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-21Merge branch 'ff/c99' into nextJunio C Hamano
* ff/c99: Remove all void-pointer arithmetic.
2006-06-20Remove all void-pointer arithmetic.Florian Forster
ANSI C99 doesn't allow void-pointer arithmetic. This patch fixes this in various ways. Usually the strategy that required the least changes was used. Signed-off-by: Florian Forster <octo@verplant.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-18diff options: add --colorJohannes Schindelin
This patch is a slightly adjusted version of Junio's patch: http://www.gelato.unsw.edu.au/archives/git/0604/19354.html However, instead of using a config variable, this patch makes it available as a diff option. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-24Merge branch 'js/fmt-patch'Junio C Hamano
This makes "git format-patch" a built-in. * js/fmt-patch: git-rebase: use canonical A..B syntax to format-patch git-format-patch: now built-in. fmt-patch: Support --attach fmt-patch: understand old <his> notation Teach fmt-patch about --keep-subject Teach fmt-patch about --numbered fmt-patch: implement -o <dir> fmt-patch: output file names to stdout Teach fmt-patch to write individual files. Use RFC2822 dates from "git fmt-patch". git-fmt-patch: thinkofix to show [PATCH] properly. rename internal format-patch wip Minor tweak on subject line in --pretty=email Tentative built-in format-patch.
2006-05-24--summary output should print immediately after stats.Sean
Currently the summary is displayed after the patch. Fix this so that the output order is stat-summary-patch. As a consequence of the way this is coded, the --summary option will only actually display summary data if combined with either the --stat or --patch-with-stat option. Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-23Avoid segfault in diff --stat rename output.Sean
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-22diff: minor option combination fix.Junio C Hamano
output_format == DIFFSTAT and with_stat == true does not make sense, and the way the code is structured it causes trouble. Avoid it. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-21checkdiff_consume: strtol parameter fix.Junio C Hamano
The second parameter is not the end of string input; it is the optional return value to retrieve where the parser stopped. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-21fmt-patch: Support --attachJohannes Schindelin
This patch touches a couple of files, because it adds options to print a custom text just after the subject of a commit, and just after the diffstat. [jc: made "many dashes" used as the boundary leader into a single variable, to reduce the possibility of later tweaks to miscount the number of dashes to break it.] Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-21diff family: add --check optionJohannes Schindelin
Actually, it is a diff option now, so you can say git diff --check to ask if what you are about to commit is a good patch. [jc: this also would work for fmt-patch, but the point is that the check is done before making a commit. format-patch is run from an already created commit, and that is too late to catch whitespace damaged change.] Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-16Merge branch 'se/diff'Junio C Hamano
* se/diff: Convert some "apply --summary" users to "diff --summary". Add "--summary" option to git diff.
2006-05-16Merge branch 'lt/diff'Junio C Hamano
* lt/diff: git diff: support "-U" and "--unified" options properly
2006-05-15diffstat rename squashing fix.Junio C Hamano
When renaming leading/a/filename to leading/b/filename (and "filename" is sufficiently long), we tried to squash the rename to "leading/{a => b}/filename". However, when "/a" or "/b" part is empty, we underflowed and tried to print a substring of length -1. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-14Add "--summary" option to git diff.Sean
Remove the need to pipe git diff through git apply to get the extended headers summary. Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-14git diff: support "-U" and "--unified" options properlyLinus Torvalds
We used to parse "-U" and "--unified" as part of the GIT_DIFF_OPTS environment variable, but strangely enough we would _not_ parse them as part of the normal diff command line (where we only accepted "-u"). This adds parsing of -U and --unified, both with an optional numeric argument. So now you can just say git diff --unified=5 to get a unified diff with a five-line context, instead of having to do something silly like GIT_DIFF_OPTS="--unified=5" git diff -u (that silly format does continue to still work, of course). Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>