summaryrefslogtreecommitdiff
path: root/diff.c
AgeCommit message (Collapse)AuthorFilesLines
2006-06-28diff.c: fix get_patch_id()Libravatar Junio C Hamano1-1/+1
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-26add diff_flush_patch_id() to calculate the patch idLibravatar Johannes Schindelin1-0/+139
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'Libravatar Junio C Hamano1-14/+80
* jc/diff: diff --color: use $GIT_DIR/config
2006-06-26Merge branch 'js/diff'Libravatar Junio C Hamano1-4/+9
* js/diff: Teach diff about -b and -w flags
2006-06-25diff --color: use $GIT_DIR/configLibravatar Junio C Hamano1-14/+80
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-24Clean up diff.cLibravatar Timo Hirvonen1-12/+6
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.Libravatar Junio C Hamano1-1/+1
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-23Teach diff about -b and -w flagsLibravatar Johannes Schindelin1-4/+9
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 colorsLibravatar Linus Torvalds1-41/+58
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 nextLibravatar Junio C Hamano1-1/+1
* ff/c99: Remove all void-pointer arithmetic.
2006-06-20Remove all void-pointer arithmetic.Libravatar Florian Forster1-1/+1
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-17diff options: add --colorLibravatar Johannes Schindelin1-9/+70
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'Libravatar Junio C Hamano1-1/+5
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-23--summary output should print immediately after stats.Libravatar Sean1-1/+4
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-22Avoid segfault in diff --stat rename output.Libravatar Sean1-1/+1
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-22diff: minor option combination fix.Libravatar Junio C Hamano1-0/+8
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.Libravatar Junio C Hamano1-1/+1
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 --attachLibravatar Johannes Schindelin1-1/+5
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 optionLibravatar Johannes Schindelin1-1/+114
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-15Merge branch 'se/diff'Libravatar Junio C Hamano1-1/+87
* se/diff: Convert some "apply --summary" users to "diff --summary". Add "--summary" option to git diff.
2006-05-15Merge branch 'lt/diff'Libravatar Junio C Hamano1-1/+51
* lt/diff: git diff: support "-U" and "--unified" options properly
2006-05-14diffstat rename squashing fix.Libravatar Junio C Hamano1-2/+7
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.Libravatar Sean1-1/+87
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 properlyLibravatar Linus Torvalds1-1/+51
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>
2006-05-09Merge branch 'jc/bindiff'Libravatar Junio C Hamano1-7/+107
* jc/bindiff: improve base85 generated assembly code binary diff and apply: testsuite. binary diff: further updates. binary patch.
2006-05-08Merge branch 'fix'Libravatar Junio C Hamano1-1/+1
* fix: Separate object name errors from usage errors Documentation: {caret} fixes (git-rev-list.txt) Fix "git diff --stat" with long filenames Fix repo-config set-multivar error return path.
2006-05-08Fix "git diff --stat" with long filenamesLibravatar Linus Torvalds1-1/+1
When we cut off the front of a filename to make it fit on the line, we add a "..." in front. However, the way the "git diff" code was written, we will never reset the prefix back to the empty string, so every single filename afterwards will have the "..." prefix, whether appropriate or not. You can see this with "git diff v2.6.16.." on the current kernel tree, since there are filenames with long names that changed there: [ snip snip ] Documentation/filesystems/vfs.txt | 229 .../firmware_class/firmware_sample_driver.c | 3 .../firmware_sample_firmware_class.c | 1 ...Documentation/fujitsu/frv/kernel-ABI.txt | 192 ...Documentation/hwmon/w83627hf | 4 [ snip snip ] notice how the two Documentation/firmware** filenames caused the "..." to be added, but then the later filenames don't want it, and it also screws up the alignment of the line numbering afterwards. Trivially fixed by moving the declaration (and initial setting) of the "prefix" variable into the for-loop where it is used. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-05binary diff: further updates.Libravatar Junio C Hamano1-63/+71
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>
2006-05-05binary patch.Libravatar Junio C Hamano1-7/+99
This adds "binary patch" to the diff output and teaches apply what to do with them. On the diff generation side, traditionally, we said "Binary files differ\n" without giving anything other than the preimage and postimage object name on the index line. This was good enough for applying a patch generated from your own repository (very useful while rebasing), because the postimage would be available in such a case. However, this was not useful when the recipient of such a patch via e-mail were to apply it, even if the preimage was available. This patch allows the diff to generate "binary" patch when operating under --full-index option. The binary patch follows the usual extended git diff headers, and looks like this: "GIT binary patch\n" <length byte><data>"\n" ... "\n" Each line is prefixed with a "length-byte", whose value is upper or lowercase alphabet that encodes number of bytes that the data on the line decodes to (1..52 -- 'A' means 1, 'B' means 2, ..., 'Z' means 26, 'a' means 27, ...). <data> is 1 or more groups of 5-byte sequence, each of which encodes up to 4 bytes in base85 encoding. Because 52 / 4 * 5 = 65 and we have the length byte, an output line is capped to 66 characters. The payload is the same diff-delta as we use in the packfiles. On the consumption side, git-apply now can decode and apply the binary patch when --allow-binary-replacement is given, the diff was generated with --full-index, and the receiving repository has the preimage blob, which is the same condition as it always required when accepting an "Binary files differ\n" patch. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-03sha1_to_hex() usage cleanupLibravatar Linus Torvalds1-4/+2
Somebody on the #git channel complained that the sha1_to_hex() thing uses a static buffer which caused an error message to show the same hex output twice instead of showing two different ones. That's pretty easily rectified by making it uses a simple LRU of a few buffers, which also allows some other users (that were aware of the buffer re-use) to be written in a more straightforward manner. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-25diff --stat: show complete rewrites consistently.Libravatar Junio C Hamano1-4/+14
The patch format shows complete rewrite as deletion of all old lines followed by addition of all new lines. Count lines consistenly with that when doing diffstat. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-22Libify diff-files.Libravatar Junio C Hamano1-0/+1795
This is the first installment to libify diff brothers. The updated diff-files uses revision.c::setup_revisions() infrastructure to parse its command line arguments, which means the pathname arguments are checked more strictly than before. The tests are adjusted to separate possibly missing paths from the rest of arguments with double-dashes, to show the kosher way. As Linus pointed out, renaming diff.c to diff-lib.c was simply stupid, so I am renaming it back. The new diff-lib.c is to contain pieces extracted from diff brothers. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-19diff: move diff.c to diff-lib.c to make room.Libravatar Junio C Hamano1-1736/+0
Now I am not doing any real "git-diff in C" yet, but this would help before doing so. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-19Merge branch 'fix'Libravatar Junio C Hamano1-3/+4
* fix: Document git-clone --reference Fix filename scaling for binary files
2006-04-18Fix filename scaling for binary filesLibravatar Jonas Fonseca1-3/+4
Set maximum filename length for binary files so that scaling won't be triggered and result in invalid string access. Signed-off-by: Jonas Fonseca <fonseca@diku.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18Fix "git log --stat": make sure to set recursive with --stat.Libravatar Junio C Hamano1-0/+9
Just like "patch" format always needs recursive, "diffstat" format does not make sense without setting recursive. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-18diff --stat: make sure to set recursive.Libravatar Junio C Hamano1-0/+10
Just like "patch" format always needs recursive, "diffstat" format does not make sense without setting recursive. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-15diff-options: add --patch-with-statLibravatar Johannes Schindelin1-1/+16
With this option, git prepends a diffstat in front of the patch. Since I really, really do not know what a diffstat of a combined diff ("merge diff") should look like, the diffstat is not generated for these. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-15diff-files --stat: do not dump core with unmerged index.Libravatar Junio C Hamano1-4/+17
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-15diff --stat: do not do its own three-dashes.Libravatar Junio C Hamano1-2/+0
I missed that "git-diff-* --stat" spits out three-dash separator on its own without being asked. Remove it. When we output commit log followed by diff, perhaps --patch-with-stat, for downstream consumer, we _would_ want the three-dash between the message and the diff material, but that logic belongs to the caller, not diff generator. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-13diff --stat: no need to ask funcnames nor context.Libravatar Junio C Hamano1-2/+2
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-13diff-options: add --stat (take 2)Libravatar Johannes Schindelin1-5/+5
... and a fix for an invalid free(): Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-13diff-options: add --stat (take 2)Libravatar Johannes Schindelin1-5/+217
Now, you can say "git diff --stat" (to get an idea how many changes are uncommitted), or "git log --stat". Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-11Separate the raw diff and patch with a newlineLibravatar Petr Baudis1-0/+1
More friendly for human reading I believe, and possibly friendlier to some parsers (although only by an epsilon). Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-10diff-* --patch-with-rawLibravatar Junio C Hamano1-33/+49
This new flag outputs the diff-raw output and diff-patch output at the same time. Requested by Cogito. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-10Retire diffcore-pathspec.Libravatar Junio C Hamano1-2/+0
Nobody except diff-stages used it -- the callers instead filtered the input to diffcore themselves. Make diff-stages do that as well and retire diffcore-pathspec. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-08diff: fix output of total-rewrite diff.Libravatar Junio C Hamano1-2/+3
We did not read in the file data before emitting the total-rewrite diff. Noticed by Pasky. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-05Merge branches 'master' and 'jc/combine' into nextLibravatar Junio C Hamano1-19/+25
* master: Add git-clean command diff_flush(): leakfix. parse_date(): fix parsing 03/10/2006 * jc/combine: combine-diff: refactor built-in xdiff interface.
2006-04-05Merge branch 'fix'Libravatar Junio C Hamano1-19/+25
* fix: diff_flush(): leakfix. parse_date(): fix parsing 03/10/2006
2006-04-05diff_flush(): leakfix.Libravatar Junio C Hamano1-19/+25
We were leaking filepairs when output-format was set to NO_OUTPUT. Signed-off-by: Junio C Hamano <junkio@cox.net>