summaryrefslogtreecommitdiff
path: root/combine-diff.c
AgeCommit message (Collapse)AuthorFilesLines
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>
2006-01-28diff-files: -c and --cc options.Libravatar Junio C Hamano1-20/+46
This ports the "combined diff" to diff-files so that differences to the working tree files since stage 2 and stage 3 are shown the same way as combined diff output from diff-tree for the merge commit would be shown if the current working tree files are committed. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-28combine-diff: better hunk splitting.Libravatar Junio C Hamano1-27/+116
It considered an otherwise unchanged line that had line removals in front of it an interesting line, which caused hunks to have one extra the trailing context line. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-28diff-tree --cc: squelch header generation on empty patch.Libravatar Junio C Hamano1-16/+30
Earlier round showed the commit log header and "diff --combined" header even for paths that had no interesting hunk under --cc flag. Move the header display logic around to squelch them. With this, a merge that does not have any interesting merges will not be shown with --cc option, unless -m is used at the same time. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-28combine-diff: extend --cc logic to Octopus.Libravatar Junio C Hamano1-26/+63
Santi Bejar points out that a hunk that changes from all the same common parents except one is uninteresting. The earlier round marked changes from only one parent uninteresting, but this also marks hunks that have the same change from all but one parent uninteresting, which is a natural extension of the original idea to Octopus merges. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-28combine-diff: minor output changes.Libravatar Junio C Hamano1-3/+2
Remove extra whitespace between the change indicators and the body text. That is more in line with the uncombined unified diff output (pointed out by Santi Bejar). When showing --cc, say so instead of saying just --combined. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-28combine-diff: fix appending at the tail of a list.Libravatar Junio C Hamano1-11/+6
... and use the established pattern of tail initialized to point at the head pointer for an empty list, and updated to point at the next pointer field of the item at the tail when appending. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-28diff-tree --cc: denser combined diff output for a merge commit.Libravatar Junio C Hamano1-5/+64
Building on the previous '-c' (combined) option, '--cc' option squelches the output further by omitting hunks that consist of difference with solely one parent. Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-28diff-tree -c: show a merge commit a bit more sensibly.Libravatar Junio C Hamano1-0/+469
A new option '-c' to diff-tree changes the way a merge commit is displayed when generating a patch output. It shows a "combined diff" (hence the option letter 'c'), which looks like this: $ git-diff-tree --pretty -c -p fec9ebf1 | head -n 18 diff-tree fec9ebf... (from parents) Merge: 0620db3... 8a263ae... Author: Junio C Hamano <junkio@cox.net> Date: Sun Jan 15 22:25:35 2006 -0800 Merge fixes up to GIT 1.1.3 diff --combined describe.c @@@ +98,7 @@@ return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; } - static void describe(char *arg) - static void describe(struct commit *cmit, int last_one) ++ static void describe(char *arg, int last_one) { + unsigned char sha1[20]; + struct commit *cmit; There are a few things to note about this feature: - The '-c' option implies '-p'. It also implies '-m' halfway in the sense that "interesting" merges are shown, but not all merges. - When a blob matches one of the parents, we do not show a diff for that path at all. For a merge commit, this option shows paths with real file-level merge (aka "interesting things"). - As a concequence of the above, an "uninteresting" merge is not shown at all. You can use '-m' in addition to '-c' to show the commit log for such a merge, but there will be no combined diff output. - Unlike "gitk", the output is monochrome. A '-' character in the nth column means the line is from the nth parent and does not appear in the merge result (i.e. removed from that parent's version). A '+' character in the nth column means the line appears in the merge result, and the nth parent does not have that line (i.e. added by the merge itself or inherited from another parent). The above example output shows that the function signature was changed from either parents (hence two "-" lines and a "++" line), and "unsigned char sha1[20]", prefixed by a " +", was inherited from the first parent. The code as sent to the list was buggy in few corner cases, which I have fixed since then. It does not bother to keep track of and show the line numbers from parent commits, which it probably should. Signed-off-by: Junio C Hamano <junkio@cox.net>