aboutsummaryrefslogtreecommitdiff
path: root/diff.c
Commit message (Collapse)AuthorAge
* Colorize 'commit' lines in log uiJeff King2006-07-24
| | | | | | | | | | | | | | 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>
* diff: Support 256 colorsTimo Hirvonen2006-07-13
| | | | | | | | 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>
* diff: Support both attributes and colorsTimo Hirvonen2006-07-13
| | | | | | | | | | | | | | | | 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>
* Avoid C99 initializersShawn Pearce2006-07-10
| | | | | | | | | | 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>
* Merge branch 'ew/diff'Junio C Hamano2006-07-09
|\ | | | | | | | | | | | | | | | | * 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
| * diff: do not use configuration magic at the core-levelJunio C Hamano2006-07-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * diff.c: --no-color to defeat diff.color configuration.Junio C Hamano2006-07-07
| | | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
| * diff.c: respect diff.renames config optionEric Wong2006-07-07
| | | | | | | | | | | | | | | | | | | | | | 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>
* | "git -p cmd" to page anywhereJunio C Hamano2006-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'sf/diff'Junio C Hamano2006-07-09
|\ \ | |/
| * Teach diff -a as shorthand for --textStephan Feder2006-07-07
| | | | | | | | | | Signed-off-by: Stephan Feder <sf@b-i-t.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
| * Teach --text option to diffStephan Feder2006-07-07
| | | | | | | | | | | | | | | | 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>
* | colored diff: diff.color = auto fixJunio C Hamano2006-07-07
|/ | | | | | | | 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>
* Do not drop data from '\0' until eol in patch outputStephan Feder2006-07-07
| | | | | | | | 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>
* Merge branch 'th/diff'Junio C Hamano2006-07-05
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
| * Fix some more diff options changes.Junio C Hamano2006-06-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Fix diff-tree -sTimo Hirvonen2006-06-27
| | | | | | | | | | | | | | | | | | | | | | 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>
| * Print empty line between raw, stat, summary and patchTimo Hirvonen2006-06-27
| | | | | | | | | | Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
| * Don't xcalloc() struct diffstat_tTimo Hirvonen2006-06-26
| | | | | | | | | | Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
| * Add msg_sep to diff_optionsTimo Hirvonen2006-06-26
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Set default diff output format after parsing command lineTimo Hirvonen2006-06-26
| | | | | | | | | | | | | | | | | | 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>
| * Make --raw option available for all diff commandsTimo Hirvonen2006-06-26
| | | | | | | | | | Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
| * Merge with_raw, with_stat and summary variables to output_formatTimo Hirvonen2006-06-26
| | | | | | | | | | | | | | 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>
* | Make zlib compression level configurable, and change default.Joachim B Haga2006-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | diff.c: fix get_patch_id()Junio C Hamano2006-06-28
| | | | | | | | | | | | | | 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>
* | add diff_flush_patch_id() to calculate the patch idJohannes Schindelin2006-06-26
|/ | | | | | | | | | | 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>
* Merge branch 'jc/diff'Junio C Hamano2006-06-26
|\ | | | | | | | | * jc/diff: diff --color: use $GIT_DIR/config
| * diff --color: use $GIT_DIR/configJunio C Hamano2006-06-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge branch 'js/diff'Junio C Hamano2006-06-26
|\ \ | |/ |/| | | | | * js/diff: Teach diff about -b and -w flags
| * Teach diff about -b and -w flagsJohannes Schindelin2006-06-23
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Clean up diff.cTimo Hirvonen2006-06-24
| | | | | | | | | | Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | diff --color: use reset sequence when we mean reset.Junio C Hamano2006-06-24
|/ | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* Tweak diff colorsLinus Torvalds2006-06-22
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge branch 'ff/c99' into nextJunio C Hamano2006-06-21
|\ | | | | | | | | * ff/c99: Remove all void-pointer arithmetic.
| * Remove all void-pointer arithmetic.Florian Forster2006-06-20
| | | | | | | | | | | | | | | | 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>
* | diff options: add --colorJohannes Schindelin2006-06-17
|/ | | | | | | | | | | 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>
* Merge branch 'js/fmt-patch'Junio C Hamano2006-05-24
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * fmt-patch: Support --attachJohannes Schindelin2006-05-21
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | --summary output should print immediately after stats.Sean2006-05-23
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Avoid segfault in diff --stat rename output.Sean2006-05-22
| | | | | | | | | | Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | diff: minor option combination fix.Junio C Hamano2006-05-22
| | | | | | | | | | | | | | 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>
* | checkdiff_consume: strtol parameter fix.Junio C Hamano2006-05-21
|/ | | | | | | 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>
* diff family: add --check optionJohannes Schindelin2006-05-21
| | | | | | | | | | | | | | | | 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>
* Merge branch 'se/diff'Junio C Hamano2006-05-15
|\ | | | | | | | | | | * se/diff: Convert some "apply --summary" users to "diff --summary". Add "--summary" option to git diff.
| * Add "--summary" option to git diff.Sean2006-05-14
| | | | | | | | | | | | | | | | 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>
* | Merge branch 'lt/diff'Junio C Hamano2006-05-15
|\ \ | | | | | | | | | | | | * lt/diff: git diff: support "-U" and "--unified" options properly
| * | git diff: support "-U" and "--unified" options properlyLinus Torvalds2006-05-14
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | diffstat rename squashing fix.Junio C Hamano2006-05-14
|/ | | | | | | | | | 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>
* Merge branch 'jc/bindiff'Junio C Hamano2006-05-09
|\ | | | | | | | | | | | | | | * jc/bindiff: improve base85 generated assembly code binary diff and apply: testsuite. binary diff: further updates. binary patch.
| * binary diff: further updates.Junio C Hamano2006-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates the user interface and generated diff data format. * "diff --binary" is used to signal that we want an e-mailable binary patch. It implies --full-index and -p. * "apply --allow-binary-replacement" acquired a short synonym "apply --binary". * After the "GIT binary patch\n" header line there is a token to record which binary patch mechanism was used, so that we can extend it later. Currently there are two mechanisms defined: "literal" and "delta". The former records the deflated postimage and the latter records the deflated delta from the preimage to postimage. For purely implementation convenience, I added the deflated length after these "literal/delta" tokens (otherwise the decoding side needs to guess and reallocate the buffer while inflating). Improvement patches are very welcomed. Signed-off-by: Junio C Hamano <junkio@cox.net>