summaryrefslogtreecommitdiff
path: root/combine-diff.c
AgeCommit message (Collapse)AuthorFilesLines
2006-08-13Fix type of combine-diff.c::show_patch_diff()Libravatar Junio C Hamano1-7/+5
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>
2006-08-10combine-diff: use colorLibravatar Junio C Hamano1-16/+34
Using the same mechanism as the regular diffs, color combined diff output. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-25Substitute xmalloc()+memset(0) with xcalloc().Libravatar Peter Eriksen1-2/+1
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-10Fix more typos, primarily in the codeLibravatar Pavel Roskin1-1/+1
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>
2006-07-05Merge branch 'th/diff'Libravatar Junio C Hamano1-34/+34
* 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-06-28combine-diff.c: type sanity.Libravatar Junio C Hamano1-1/+1
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>
2006-06-28combine-diff.c: type sanityLibravatar Junio C Hamano1-14/+15
- 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>
2006-06-27Fix some more diff options changes.Libravatar Junio C Hamano1-9/+15
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-26Add msg_sep to diff_optionsLibravatar Timo Hirvonen1-3/+4
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-26Merge with_raw, with_stat and summary variables to output_formatLibravatar Timo Hirvonen1-31/+24
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-05-14git diff: support "-U" and "--unified" options properlyLibravatar Linus Torvalds1-0/+1
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-04-29built-in diff: assorted updates.Libravatar Junio C Hamano1-17/+30
"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>
2006-04-18Merge branch 'lt/logopt'Libravatar Junio C Hamano1-35/+54
* 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
2006-04-17combine-diff: show diffstat with the first parent.Libravatar Junio C Hamano1-5/+19
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>
2006-04-17Log message printout cleanups (#2)Libravatar Linus Torvalds1-6/+16
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>
2006-04-17Log message printout cleanupsLibravatar Linus Torvalds1-26/+21
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>
2006-04-17cleanups: Remove unused vars from combine-diff.cLibravatar Serge E. Hallyn1-10/+2
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>
2006-04-12Merge branch 'jc/combine' into nextLibravatar Junio C Hamano1-2/+2
* 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.
2006-04-12combine-diff: type fix.Libravatar Junio C Hamano1-2/+2
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>
2006-04-11Merge branch 'jc/combine' into nextLibravatar Junio C Hamano1-26/+37
* jc/combine: combine-diff: fix hunks at the end (take #2). combine-diff: do not lose hunks with only deletion at end.
2006-04-11combine-diff: fix hunks at the end (take #2).Libravatar Junio C Hamano1-28/+21
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>
2006-04-11combine-diff: do not lose hunks with only deletion at end.Libravatar Junio C Hamano1-11/+29
We used to lose hunks that appear at the end and have only deletion. This makes sure that the record beyond the end of file (which holds such deletions) is examined. 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-0/+11
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-06Match ofs/cnt types in diff interface.Libravatar Junio C Hamano1-1/+2
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-05combine-diff: move the code to parse hunk-header into common library.Libravatar Junio C Hamano1-46/+0
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-05combine-diff: refactor built-in xdiff interface.Libravatar Junio C Hamano1-45/+7
This refactors the line-by-line callback mechanism used in combine-diff so that other programs can reuse it more easily. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-04combine-diff: use built-in xdiff.Libravatar Junio C Hamano1-102/+136
Now there is no GNU diff invocations, except the one from blame.c Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-04Use blob_, commit_, tag_, and tree_type throughout.Libravatar Peter Eriksen1-1/+2
This replaces occurences of "blob", "commit", "tag", and "tree", where they're really used as type specifiers, which we already have defined global constants for. Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-29tree/diff header cleanup.Libravatar Junio C Hamano1-1/+1
Introduce tree-walk.[ch] and move "struct tree_desc" and associated functions from various places. Rename DIFF_FILE_CANON_MODE(mode) macro to canon_mode(mode) and move it to cache.h. This macro returns the canonicalized st_mode value in the host byte order for files, symlinks and directories -- to be compared with a tree_desc entry. create_ce_mode(mode) in cache.h is similar but is intended to be used for index entries (so it does not work for directories) and returns the value in the network byte order. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-27combine-diff: Honour -z option correctly.Libravatar Mark Wooding1-2/+2
Combined diffs don't null terminate things in the same way as standard diffs. This is presumably wrong. Signed-off-by: Mark Wooding <mdw@distorted.org.uk> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-27combine-diff: Honour --full-index.Libravatar Mark Wooding1-4/+6
For some reason, combined diffs don't honour the --full-index flag when emitting patches. Fix this. Signed-off-by: Mark Wooding <mdw@distorted.org.uk> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-13combine-diff: diff-files fix.Libravatar Junio C Hamano1-4/+5
When showing a conflicted merge from index stages and working tree file, we did not fetch the mode from the working tree, and mistook that as a deleted file. Also if the manual resolution (or automated resolution by git rerere) ended up taking either parent's version, we did not show _anything_ for that path. Either was quite bad and confusing. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-10combine-diff: Record diff status a bit more faithfullyLibravatar Junio C Hamano1-7/+25
This shows "new file mode XXXX" and "deleted file mode XXXX" lines like two-way diff-patch output does, by checking the status from each parent. The diff-raw output for combined diff is made a bit uglier by showing diff status letters with each parent. While most of the case you would see "MM" in the output, an Evil Merge that touches a path that was added by inheriting from one parent is possible and it would be shown like these: $ git-diff-tree --abbrev -c HEAD 2d7ca89675eb8888b0b88a91102f096d4471f09f ::000000 000000 100644 0000000... 0000000... 31dd686... AA b ::000000 100644 100644 0000000... 6c884ae... c6d4fa8... AM d ::100644 100644 100644 4f7cbe7... f8c295c... 19d5d80... RR e Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-10find_unique_abbrev() simplification.Libravatar Junio C Hamano1-12/+3
Earlier it did not grok the 0{40} SHA1 very well, but what it needed to do was to find the shortest 0{N} that is not used as a valid object name to be consistent with the way names of valid objects are abbreviated. This makes some users simpler. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-09combine-diff: move formatting logic to show_combined_diff()Libravatar Junio C Hamano1-27/+58
This way, diff-files can make use of it. Also implement the full suite of what diff_flush_raw() supports just for consistency. With this, 'diff-tree -c -r --name-status' would show what is expected. There is no way to get the historical output (useful for debugging and low-level Plumbing work) anymore, so tentatively it makes '-m' to mean "do not combine and show individual diffs with parents". diff-files matches diff-tree to produce raw output for -c. For textual combined diff, use -p -c. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-09combined-diff: use diffcore before intersecting paths.Libravatar Junio C Hamano1-1/+2
This is needed to make "diff-tree -c -M" to work semi-sensibly. Otherwise rename detection, pickaxe and friends would never be invoked. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-09diff-tree -c raw outputLibravatar Linus Torvalds1-3/+52
NOTE! This makes "-c" be the default, which effectively means that merges are never ignored any more, and "-m" is a no-op. So it changes semantics. I would also like to make "--cc" the default if you do patches, but didn't actually do that. The raw output format is not wonderfully pretty, but it's distinguishable from a "normal patch" in that a normal patch with just one parent has just one colon at the beginning, while a multi-parent raw diff has <n> colons for <n> parents. So now, in the kernel, when you do git-diff-tree cce0cac125623f9b68f25dd1350f6d616220a8dd (to see the manual ARM merge that had a conflict in arch/arm/Kconfig), you get cce0cac125623f9b68f25dd1350f6d616220a8dd ::100644 100644 100644 4a63a8e2e45247a11c068c6ed66c6e7aba29ddd9 77eee38762d69d3de95ae45dd9278df9b8225e2c 2f61726d2f4b636f6e66696700dbf71a59dad287 arch/arm/Kconfig ie you see two colons (two parents), then three modes (parent modes followed by result mode), then three sha1s (parent sha1s followed by result sha1). Which is pretty close to the normal raw diff output. Cool/stupid exercise: $ git-whatchanged | grep '^::' | cut -f2- | sort | uniq -c | sort -n | less -S will show which files have needed the most file-level merge conflict resolution. Useful? Probably not. But kind of interesting. For the kernel, it's .... 10 arch/ia64/Kconfig 11 drivers/scsi/Kconfig 12 drivers/net/Makefile 17 include/linux/libata.h 18 include/linux/pci_ids.h 23 drivers/net/Kconfig 24 drivers/scsi/libata-scsi.c 28 drivers/scsi/libata-core.c 43 MAINTAINERS Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-06combine-diff: do not punt on removed or added files.Libravatar Junio C Hamano1-10/+14
When we remove a file, the parents' contents are all removed so it is not that interesting to show all of them, but the fact it was removed when all parents had it *is* unusual. When we add a file, similarly the fact it was added when no parent wanted it *is* unusual, and in addition the result matters, so show it. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-06combine-diff: show mode changes as well.Libravatar Junio C Hamano1-11/+31
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-06combine-diff: do not send NULL to printfLibravatar Junio C Hamano1-6/+17
When we run combined diff from working tree (diff-files --cc), we sent NULL to printf that is returned by find_unique_abbrev(). Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-05combine-diff: remove misguided --show-empty hack.Libravatar Junio C Hamano1-6/+4
Now --always flag is available in diff-tree, there is no reason to have that hack in the diffcore side. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-02combine-diff: finishing touches to git-diff-tree --ccLibravatar Junio C Hamano1-4/+4
This updates the output format to make administrative lines more consistent with the traditional diffs. The "index" line shows blob object names from each parents (separated by commas), double dots and the object name of the resulting blob. The hunk header line begins with N+1 '@' characters for N-way diff, the line number L of the first line in the hunk and line count C from the parent in "-L,C" format for each parents and then the line number of the first line in the hunk and line count from the resulting file in "+L,C" format, and finally N+1 '@' characters (earlier versions had the line numbers from the resulting file at the beginning). Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-02combine-diff: cleanup.Libravatar Junio C Hamano1-37/+65
The flag on the surviving lines meant "this parent is not different" while the parent_map flag on the lost lines meant "this parent is different", which was confusing. So swap the meaning of on-bit in the flag. Also more heavily comment the code. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-02combine-diff: show parent line numbers as well.Libravatar Junio C Hamano1-11/+59
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-02combine-diff: add a bit more comments.Libravatar Junio C Hamano1-1/+7
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-02combine-diff: fix placement of deletion.Libravatar Junio C Hamano1-1/+13
The code misplaced a raw hunk that consists of solely deleted lines by one line. This showed e.g. Len's 12-way octopus (9fdb62af in the linux-2.6), kernel/power/disk.c, hunk starting at line 95, incorrectly. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-02combine-diff: add safety check to --cc.Libravatar Junio C Hamano1-2/+18
The earlier change implemented "only two version" check but without checking if the change rewrites from all the parents. This implements a check to make sure that a change introduced by the merge from all the parents is caught to be interesting. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-02combine-diff: update --cc "uninteresting hunks" logic.Libravatar Junio C Hamano1-69/+33
Earlier logic was discarding hunks that has difference from only one parent or the same difference from all but one parent. This changes it to check if the differences on all lines are from the same sets of parents. This discards more uninteresting hunks and seems to match expectations more naturally. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-02combine-diff: reuse diff from the same blob.Libravatar Junio C Hamano1-2/+37
When dealing with an insanely large Octopus, it is possible to optimize by noticing that more than one parents have the same blob and avoid running diff between a parent and the merge result by reusing an earlier result. Signed-off-by: Junio C Hamano <junkio@cox.net>