aboutsummaryrefslogtreecommitdiff
path: root/combine-diff.c
Commit message (Collapse)AuthorAge
* Merge branch 'jc/maint-combine-diff-pre-context'Junio C Hamano2008-06-22
|\ | | | | | | | | * jc/maint-combine-diff-pre-context: diff -c/--cc: do not include uninteresting deletion before leading context
| * diff -c/--cc: do not include uninteresting deletion before leading contextJunio C Hamano2008-06-18
| | | | | | | | | | | | | | | | | | When we include a few uninteresting lines before the interesting ones as context, we are only interested in seeing the surviving lines themselves and not the deleted lines that are before them. Mark the added leading context lines in give_context() and not show deleted lines form them. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Cleanup xread() loops to use read_in_full()Heikki Orsila2008-05-03
| | | | | | | | | | Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Remove dead code: show_log() sep argument and diff_options.msg_sepAdam Simpkins2008-05-03
| | | | | | | | | | | | | | | | These variables were made unnecessary by commit 3969cf7db1a13a78f3b7a36d8c1084bbe0a53459. Signed-off-by: Adam Simpkins <adam@adamsimpkins.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Die for an early EOF in a file reading loopHeikki Orsila2008-04-27
|/ | | | | | | | The resulting data is zero terminated after the read loop, but the subsequent loop that scans for '\n' will overrun the buffer. Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix rewrite_diff() name quoting.Junio C Hamano2007-12-26
| | | | | | | | | This moves the logic to quote two paths (prefix + path) in C-style introduced in the previous commit from the dump_quoted_path() in combine-diff.c to quote.c, and uses it to fix rewrite_diff() that never C-quoted the pathnames correctly. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* combine-diff: Fix path quotingJunio C Hamano2007-12-26
| | | | | | | | | | | | Earlier when showing combined diff, the filenames on the ---/+++ header lines were quoted incorrectly. a/ (or b/) prefix was output literally and then the path was output, with c-quoting. This fixes the quoting logic, and while at it, adjusts the code to use the customizable prefix (a_prefix and b_prefix) introduced recently. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* xdl_diff: identify call sites.Junio C Hamano2007-12-13
| | | | | | | | This inserts a new function xdi_diff() that currently does not do anything other than calling the underlying xdl_diff() to the callchain of current callers of xdl_diff() function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make the diff_options bitfields be an unsigned with explicit masks.Pierre Habouzit2007-11-11
| | | | | | | reverse_diff was a bit-value in disguise, it's merged in the flags now. Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Full rework of quote_c_style and write_name_quoted.Pierre Habouzit2007-09-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | * quote_c_style works on a strbuf instead of a wild buffer. * quote_c_style is now clever enough to not add double quotes if not needed. * write_name_quoted inherits those advantages, but also take a different set of arguments. Now instead of asking for quotes or not, you pass a "terminator". If it's \0 then we assume you don't want to escape, else C escaping is performed. In any case, the terminator is also appended to the stream. It also no longer takes the prefix/prefix_len arguments, as it's seldomly used, and makes some optimizations harder. * write_name_quotedpfx is created to work like write_name_quoted and take the prefix/prefix_len arguments. Thanks to those API changes, diff.c has somehow lost weight, thanks to the removal of functions that were wrappers around the old write_name_quoted trying to give it a semantics like the new one, but performing a lot of allocations for this goal. Now we always write directly to the stream, no intermediate allocation is performed. As a side effect of the refactor in builtin-apply.c, the length of the bar graphs in diffstats are not affected anymore by the fact that the path was clipped. Signed-off-by: Pierre Habouzit <madcoder@debian.org>
* Future-proof source for changes in xdemitconf_tJohannes Schindelin2007-07-06
| | | | | | | | | | | The instances of xdemitconf_t were initialized member by member. Instead, initialize them to all zero, so we do not have to update those places each time we introduce a new member. [jc: minimally fixed by getting rid of a new global] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Ensure return value from xread() is always stored into an ssize_tJohan Herland2007-05-15
| | | | | | | | | This patch fixes all calls to xread() where the return value is not stored into an ssize_t. The patch should not have any effect whatsoever, other than putting better/more appropriate type names on variables. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Support 'diff=pgm' attributeJunio C Hamano2007-04-22
| | | | | | | | | | | | | | | | | | | | | | | | | This enhances the attributes mechanism so that external programs meant for existing GIT_EXTERNAL_DIFF interface can be specifed per path. To configure such a custom diff driver, first define a custom diff driver in the configuration: [diff "my-c-diff"] command = <<your command string comes here>> Then mark the paths that you want to use this custom driver using the attribute mechanism. *.c diff=my-c-diff The intent of this separation is that the attribute mechanism is used for specifying the type of the contents, while the configuration mechanism is used to define what needs to be done to that type of the contents, which would be specific to both platform and personal taste. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Cast 64 bit off_t to 32 bit size_tShawn O. Pearce2007-03-07
| | | | | | | | | | | | | | | | | | Some systems have sizeof(off_t) == 8 while sizeof(size_t) == 4. This implies that we are able to access and work on files whose maximum length is around 2^63-1 bytes, but we can only malloc or mmap somewhat less than 2^32-1 bytes of memory. On such a system an implicit conversion of off_t to size_t can cause the size_t to wrap, resulting in unexpected and exciting behavior. Right now we are working around all gcc warnings generated by the -Wshorten-64-to-32 option by passing the off_t through xsize_t(). In the future we should make xsize_t on such problematic platforms detect the wrapping and die if such a file is accessed. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Tell multi-parent diff about core.symlinks.Johannes Sixt2007-03-03
| | | | | | | | | | | When core.symlinks is false, and a merge of symbolic links had conflicts, the merge result is left as a file in the working directory. A decision must be made whether the file is treated as a regular file or as a symbolic link. This patch treats the file as a symbolic link only if all merge parents were also symbolic links. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <junkio@cox.net>
* convert object type handling from a string to a numberNicolas Pitre2007-02-27
| | | | | | | | | | | | | | | We currently have two parallel notation for dealing with object types in the code: a string and a numerical value. One of them is obviously redundent, and the most used one requires more stack space and a bunch of strcmp() all over the place. This is an initial step for the removal of the version using a char array found in object reading code paths. The patch is unfortunately large but there is no sane way to split it in smaller parts without breaking the system. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* diff --cc: integer overflow given a 2GB-or-larger fileJim Meyering2007-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | Few of us use git to compare or even version-control 2GB files, but when we do, we'll want it to work. Reading a recent patch, I noticed two lines like this: int len = st.st_size; Instead of "int", that should be "size_t". Otherwise, in the non-symlink case, with 64-bit size_t, if the file's size is 2GB, the following xmalloc will fail: result = xmalloc(len + 1); trying to allocate 2^64 - 2^31 + 1 bytes (assuming sign-extension in the int-to-size_t promotion). And even if it didn't fail, the subsequent "result[len] = 0;" would be equivalent to an unpleasant "result[-2147483648] = 0;" The other nearby "int"-declared size variable, sz, should also be of type size_t, for the same reason. If sz ever wraps around and becomes negative, xread will corrupt memory _before_ the "result" buffer. Signed-off-by: Jim Meyering <jim@meyering.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
* diff --cc: fix display of symlink conflicts during a merge.Junio C Hamano2007-02-25
| | | | | | | | "git-diff-files --cc" to show conflicts during merge did not pass the correct mode information for the working tree down, and showed bogus combined diff. Signed-off-by: Junio C Hamano <junkio@cox.net>
* combine-diff: special case --unified=0Junio C Hamano2007-02-03
| | | | | | | | | | Even when --unified=0 is given, the main loop to show the combined textual diff needs to handle a line that is unchanged but has lines that were deleted relative to a parent before it (because that is where the lost lines hang). However, such a line should not be emitted in the final output. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'jc/combined'Junio C Hamano2006-10-26
|\ | | | | | | | | | | * jc/combined: combine-diff: honour --no-commit-id combine-diff: fix hunk_comment_line logic.
| * combine-diff: honour --no-commit-idJunio C Hamano2006-10-26
| | | | | | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
| * combine-diff: fix hunk_comment_line logic.Junio C Hamano2006-10-26
| | | | | | | | | | | | | | We forgot that the last element of sline[] is a sentinel without the actual line. *BLUSH* Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge branch 'jc/combined'Junio C Hamano2006-10-26
|\ \ | |/ | | | | | | | | | | | | | | * jc/combined: combine-diff: a few more finishing touches. Documentation: clarify refname disambiguation rules. diff-format.txt: Combined diff format documentation supplement Remove --syslog in git-daemon inetd documentation examples. Documentation: updates to "Everyday GIT"
| * combine-diff: a few more finishing touches.Junio C Hamano2006-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "new file" and "deleted file" were already reported in the original code, but the logic was not as transparent as it could have. This uses a few variables and more comments to clarify the flow. The rule is: (1) if a path exists in the merge result when no parent had it, we report "new" (otherwise it came from the parents, as opposed to have added by the evil merge). (2) if the path does not exist in the merge result, it is "deleted". Since we can say "new" and "deleted", there is no reason not to follow the /dev/null convention. This fixes it. Appending function name after @@@ ... @@@ is trivial, so implement it. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | diff --numstatJunio C Hamano2006-10-13
|/ | | | | | [jc: with documentation from Jakub] Signed-off-by: Junio C Hamano <junkio@cox.net>
* Convert memcpy(a,b,20) to hashcpy(a,b).Shawn Pearce2006-08-23
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Do not use memcmp(sha1_1, sha1_2, 20) with hardcoded length.David Rientjes2006-08-17
| | | | | | | | | | | | | 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>
* make inline is_null_sha1 globalDavid Rientjes2006-08-15
| | | | | | | | | | 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>
* Remove combine-diff.c::uninteresting()Junio C Hamano2006-08-14
| | | | | | | A patch from David Rientjes made me realize we do not have to have this function -- just call diff_unmodified_pair() directly. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fix type of combine-diff.c::show_patch_diff()Junio C Hamano2006-08-13
| | | | | | | The other function, show_raw_diff() is void and no callers use return value from neither. Signed-off-by: Junio C Hamano <junkio@cox.net>
* combine-diff: use colorJunio C Hamano2006-08-10
| | | | | | | Using the same mechanism as the regular diffs, color combined diff output. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Substitute xmalloc()+memset(0) with xcalloc().Peter Eriksen2006-07-25
| | | | | Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fix more typos, primarily in the codePavel Roskin2006-07-10
| | | | | | | | | The only visible change is that git-blame doesn't understand "--compability" anymore, but it does accept "--compatibility" instead, which is already documented. Signed-off-by: Pavel Roskin <proski@gnu.org> 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.
| * combine-diff.c: type sanity.Junio C Hamano2006-06-28
| | | | | | | | | | | | | | | | | | In diff_tree_combined(), show_log_first boolean is initialized with rev->loginfo (pointer to a string); the intention is that if we have some string to be emitted we would want to remember that fact. Picky compilers are offended by this, so make the expression a bit type-safer. Signed-off-by: Junio C Hamano <junkio@cox.net>
| * 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>
| * 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>
| * 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>
* | combine-diff.c: type sanityJunio C Hamano2006-06-28
|/ | | | | | | | | | | | | | - combine_diff() took cnt (count) which is unsigned in nature but the parameter type was declared as "int"; - find_next() took "uninteresting" parameter, which masked a static function of the same name; - show_parent_lno() took an unused parameter "cnt"; - show_patch_diff() used a local variable in nested inner scope with the same name with different type, masking the one in the outer scope; - the last loop in show_patch_diff iterated over lines so it should use the local variable "lno" Signed-off-by: Junio C Hamano <junkio@cox.net>
* 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>
* built-in diff: assorted updates.Junio C Hamano2006-04-29
| | | | | | | | | | | | | | | | "git diff(n)" without --base, --ours, etc. defaults to --cc, which usually is the same as -p unless you are in the middle of a conflicted merge, just like the shell script version. "git diff(n) blobA blobB path" complains and dies. "git diff(n) tree0 tree1 tree2...treeN" does combined diff that shows a merge of tree1..treeN to result in tree0. Giving "-c" option to any command that defaults to "--cc" turns off dense-combined flag. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'lt/logopt'Junio C Hamano2006-04-18
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lt/logopt: Fix "git log --stat": make sure to set recursive with --stat. combine-diff: show diffstat with the first parent. git.c: LOGSIZE is unused after log printing cleanup. Log message printout cleanups (#3): fix --pretty=oneline Log message printout cleanups (#2) Log message printout cleanups rev-list --header: output format fix Fixes for option parsing log/whatchanged/show - log formatting cleanup. Simplify common default options setup for built-in log family. Tentative built-in "git show" Built-in git-whatchanged. rev-list option parser fix. Split init_revisions() out of setup_revisions() Fix up rev-list option parsing. Fix up default abbrev in setup_revisions() argument parser. Common option parsing for "git log --diff" and friends
| * combine-diff: show diffstat with the first parent.Junio C Hamano2006-04-17
| | | | | | | | | | | | | | | | | | | | | | | | | | Asking for stat (either with --stat or --patch-with-stat) gives you diffstat for the first parent, even under combine-diff. While the combined patch is useful to highlight the complexity and interaction of the parts touched by all branches when reviewing a merge commit, diffstat is a tool to assess the extent of damage the merge brings in, and showing stat with the first parent is more sensible than clever per-parent diffstat. Signed-off-by: Junio C Hamano <junkio@cox.net>
| * Log message printout cleanups (#2)Linus Torvalds2006-04-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here's a further patch on top of the previous one with cosmetic improvements (no "real" code changes, just trivial updates): - it gets the "---" before a diffstat right, including for the combined merge case. Righ now the logic is that we always use "---" when we have a diffstat, and an empty line otherwise. That's how I visually prefer it, but hey, it can be tweaked later. - I made "diff --cc/combined" add the "---/+++" header lines too. The thing won't be mistaken for a valid diff, since the "@@" lines have too many "@" characters (three or more), but it just makes it visually match a real diff, which at least to me makes a big difference in readability. Without them, it just looks very "wrong". I guess I should have taken the filename from each individual entry (and had one "---" file per parent), but I didn't even bother to try to see how that works, so this was the simple thing. With this, doing a git log --cc --patch-with-stat looks quite readable, I think. The only nagging issue - as far as I'm concerned - is that diffstats for merges are pretty questionable the way they are done now. I suspect it would be better to just have the _first_ diffstat, and always make the merge diffstat be the one for "result against first parent". Signed-off-by: Junio C Hamano <junkio@cox.net>
| * Log message printout cleanupsLinus Torvalds2006-04-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Sun, 16 Apr 2006, Junio C Hamano wrote: > > In the mid-term, I am hoping we can drop the generate_header() > callchain _and_ the custom code that formats commit log in-core, > found in cmd_log_wc(). Ok, this was nastier than expected, just because the dependencies between the different log-printing stuff were absolutely _everywhere_, but here's a patch that does exactly that. The patch is not very easy to read, and the "--patch-with-stat" thing is still broken (it does not call the "show_log()" thing properly for merges). That's not a new bug. In the new world order it _should_ do something like if (rev->logopt) show_log(rev, rev->logopt, "---\n"); but it doesn't. I haven't looked at the --with-stat logic, so I left it alone. That said, this patch removes more lines than it adds, and in particular, the "cmd_log_wc()" loop is now a very clean: while ((commit = get_revision(rev)) != NULL) { log_tree_commit(rev, commit); free(commit->buffer); commit->buffer = NULL; } so it doesn't get much prettier than this. All the complexity is entirely hidden in log-tree.c, and any code that needs to flush the log literally just needs to do the "if (rev->logopt) show_log(...)" incantation. I had to make the combined_diff() logic take a "struct rev_info" instead of just a "struct diff_options", but that part is pretty clean. This does change "git whatchanged" from using "diff-tree" as the commit descriptor to "commit", and I changed one of the tests to reflect that new reality. Otherwise everything still passes, and my other tests look fine too. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | cleanups: Remove unused vars from combine-diff.cSerge E. Hallyn2006-04-17
|/ | | | | | | Mod_type in particular sure looks like it wants to be used, but isn't. Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'jc/combine' into nextJunio C Hamano2006-04-12
|\ | | | | | | | | | | | | | | | | * jc/combine: stripspace: make sure not to leave an incomplete line. git-commit: do not muck with commit message when no_edit is set. When showing a commit message, do not lose an incomplete line. Retire t5501-old-fetch-and-upload test. combine-diff: type fix.
| * combine-diff: type fix.Junio C Hamano2006-04-12
| | | | | | | | | | | | | | The variable hunk_end points at a line number, which is represented as unsigned long by all the other variables. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Merge branch 'jc/combine' into nextJunio C Hamano2006-04-11
|\ \ | |/ | | | | | | | | * jc/combine: combine-diff: fix hunks at the end (take #2). combine-diff: do not lose hunks with only deletion at end.
| * combine-diff: fix hunks at the end (take #2).Junio C Hamano2006-04-11
| | | | | | | | | | | | | | The previous round showed the delete-only hunks at the end, but forgot to mark them interesting when they were. Signed-off-by: Junio C Hamano <junkio@cox.net>