{"thread":{"id":"17311","subject":"RFC: git diff colorization idea","startedAt":"2009-01-23T00:00:27Z","lastAt":"2009-01-23T18:40:52Z","messageCount":6,"participants":["Wincent Colaiuta","Junio C Hamano","Nanako Shiraishi","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"101581","messageId":"53497057-1ADE-4300-9F35-B218959606FE@wincent.com","threadId":"17311","inReplyTo":null,"subject":"RFC: git diff colorization idea","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2009-01-23T00:00:27Z","receivedAt":"2009-01-23T00:00:27Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"Hi,\n\nLately I've been wishing that Git's diff output were colorized in a  \nway that combines the standard line-by-line colorizing with the word- \nby-word colorizing you get with --color-words.\n\nPictures speak louder than words, so here are some to show what I mean:\n\nhttp://www.flickr.com/photos/wincent-colaiuta/sets/72157612877491482/\n\nThere you'll find:\n\n1. A couple of sample hunks colorized in the current, standard way\n\n2. The same hunks colorized with \"--color-words\"\n\n3. The same hunks as they would be colorized if you could take the  \nstandard colorization (1) and augment it with per-word highlighting  \nfrom (2)\n\n(that last hunk would probably look better with a different regex  \ndefining what a \"word\" is; in reality all that happened was that  \n\"rename|\" got added to the line, so there's no need to highlight more  \nthan that).\n\nThis is not a new idea; it's something that I find myself wanting due  \nto experience with colorization available in a number of different  \ndiff viewers. Here are some more sample shots showing how different  \nviewers do it, with varying degrees of prettiness/ugliness:\n\n- Meld: http://meld.sourceforge.net/meld_file1.png\n\n- kdiff: http://kdiff3.sourceforge.net/doc/letter_by_letter.png\n\n- Apple FileMerge: http://homepage.mac.com/kelleherk/iblog/C711669388/E464913847/Media/compare_db_filemerge.jpg\n\nNo doubt there are others, but you get the idea.\n\nWould people be interested in seeing this feature go in? I've already  \nstarted snooping around diff.c seeing what would need to be done. From  \nwhat I can tell it would require a new command-line switch (seeing as  \n\"--color\" plus \"--color-words\" already means something), and probably  \ntwo new customizable color slots (such as color.diff.new.word,  \ncolor.diff.old.word).\n\nThe approach I was thinking of taking was just grabbing the diff_words  \ninfo produced when --color-words is passed and using it to augment  \nspecialized versions of emit_line() and emit_add_line().\n\nI'm also thinking that perhaps a per-character approach might be  \nuseful here instead of a per-word one (it would make that last hunk  \nlook better in the mock-up screenshot that I posted); if I go the per- \ncharacter route then that suggests that \"--color-chars\" might be the  \nright option name, and the color slots would then be  \ncolor.diff.new.char and color.diff.old.char.\n\nAny feedback or suggestions before I get in too deep?\n\nCheers,\nWincent\n"},{"id":"101586","messageId":"7vhc3q6evi.fsf@gitster.siamese.dyndns.org","threadId":"17311","inReplyTo":"53497057-1ADE-4300-9F35-B218959606FE@wincent.com","subject":"Re: RFC: git diff colorization idea","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-23T00:32:49Z","receivedAt":"2009-01-23T00:32:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n> I'm also thinking that perhaps a per-character approach might be\n> useful here instead of a per-word one (it would make that last hunk\n> look better in the mock-up screenshot that I posted); if I go the per-\n> character route then that suggests that \"--color-chars\" might be the\n> right option name, and the color slots would then be\n> color.diff.new.char and color.diff.old.char.\n>\n> Any feedback or suggestions before I get in too deep?\n\nI personally find your \"prposal\" picture too loud to my eye.\n\nI would have expected you to propose something like this:\n\n  | _git_remote ()\n  | {\n  |-    local subcommands=\"add rm show prune <red>update</red>\"\n  |+    local subcommands=\"add <green>rename</green> rm show prune\"\n  |     local subcommand=$(__git_find_subcommand \"$subcommands\")\"\n  |     if ...\n\nif the patch were to remove update and add rename, that is.  If there is\nno deletion but only insertion, you would only see green.\n\nAnd that way you do not need new color slots.  You can use new color and\nold color as before, and the coloring will be done to highlight only the\nparts that really matter.\n\nIf you were to go this route, I suspect that showing the unchanged part on\nthe preimage line in light gray might make sense, like:\n\n  | _git_remote ()\n  | {\n  |-    <gray>local subcommands=\"add rm show prune<gray> <red>update</red>\"\n  |+    local subcommands=\"add <green>rename</green> rm show prune\"\n  |     local subcommand=$(__git_find_subcommand \"$subcommands\")\"\n  |     if ...\n\nbecause there will be the same chars/words on the postimage line anyway.\n\nJust 2c from somebody who does not like colors very much.\n"},{"id":"101617","messageId":"5034E8A9-2B17-4368-8EDF-5FEE61BB2BAD@wincent.com","threadId":"17311","inReplyTo":"7vhc3q6evi.fsf@gitster.siamese.dyndns.org","subject":"Re: RFC: git diff colorization idea","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2009-01-23T06:16:50Z","receivedAt":"2009-01-23T06:16:50Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 23/1/2009, a las 1:32, Junio C Hamano escribió:\n\n> Wincent Colaiuta <win@wincent.com> writes:\n>\n>> I'm also thinking that perhaps a per-character approach might be\n>> useful here instead of a per-word one (it would make that last hunk\n>> look better in the mock-up screenshot that I posted); if I go the  \n>> per-\n>> character route then that suggests that \"--color-chars\" might be the\n>> right option name, and the color slots would then be\n>> color.diff.new.char and color.diff.old.char.\n>>\n>> Any feedback or suggestions before I get in too deep?\n>\n> I personally find your \"prposal\" picture too loud to my eye.\n\nYes, mine too. I wouldn't actually use those colors in practice.  \n(Doubly so because the \"removed\" color looks like the \"whitespace  \nerror\" color.)\n\nI'll whip something up with non-garish defaults.\n\nCheers,\nWincent\n"},{"id":"101620","messageId":"7vfxja34hx.fsf@gitster.siamese.dyndns.org","threadId":"17311","inReplyTo":"5034E8A9-2B17-4368-8EDF-5FEE61BB2BAD@wincent.com","subject":"Re: RFC: git diff colorization idea","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-23T06:45:14Z","receivedAt":"2009-01-23T06:45:14Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n>>> Any feedback or suggestions before I get in too deep?\n>>\n>> I personally find your \"prposal\" picture too loud to my eye.\n>\n> Yes, mine too. I wouldn't actually use those colors in practice.  \n> (Doubly so because the \"removed\" color looks like the \"whitespace  \n> error\" color.)\n\nI did not mean that your choice of colors is loud.  Not at all.  What I\nmeant was the use of color _everywhere_ makes it too loud, and also the\nuse of _larger number of_ colors makes it too loud..  In other words, you\nare painting the output more than what the current output does, and that\nmade me find it too loud, no matter what the choice of colors are.\n\nYou might have misunderstood my illustration, but what I meant to suggest\nwas to leave most of the characters on both - and + lines in monochrome\n(or whatever the \"normal\" is), and paint _only_ the words that are\ndifferent.  The outcome would become _less_ colorful than the current\n\"whole -/+ lines are painted\" output, but \"only different words are\ncoloured; the words that are unmodified are left uncoloured, without\ndistracting the eyes.\"  Much less louder than even the current one, yet\ngiving more information.\n\nAs -/+ has a marker value, I think colouring them may be Ok, too.  That\nwould make something like this:\n\n  | {\n  |<red>-</red>    <gray>local subcommands=\"add rm show prune<gray> <red>update</red>\"\n  |<green>+</green>    local subcommands=\"add <green>rename</green> rm show prune\"\n  |     if ...\n"},{"id":"101633","messageId":"20090123172809.6117@nanako3.lavabit.com","threadId":"17311","inReplyTo":"7vhc3q6evi.fsf@gitster.siamese.dyndns.org","subject":"Re: RFC: git diff colorization idea","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-01-23T08:28:09Z","receivedAt":"2009-01-23T08:28:09Z","isPatch":false,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Junio C Hamano <gitster@pobox.com>:\n\n> If you were to go this route, I suspect that showing the unchanged part on\n> the preimage line in light gray might make sense, like:\n>\n>   | _git_remote ()\n>   | {\n>   |-    <gray>local subcommands=\"add rm show prune<gray> <red>update</red>\"\n>   |+    local subcommands=\"add <green>rename</green> rm show prune\"\n>   |     local subcommand=$(__git_find_subcommand \"$subcommands\")\"\n>   |     if ...\n>\n> because there will be the same chars/words on the postimage line anyway.\n\nI think this makes a lot more sense than any of the screenshot\nWIncent prepared on his web pages, and it is a much easier output\nfor users to spot which word is different by not coloring the\nunchanged word at all.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"101677","messageId":"m3iqo5yiek.fsf@localhost.localdomain","threadId":"17311","inReplyTo":"53497057-1ADE-4300-9F35-B218959606FE@wincent.com","subject":"Re: RFC: git diff colorization idea","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-01-23T18:40:52Z","receivedAt":"2009-01-23T18:40:52Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n> Lately I've been wishing that Git's diff output were colorized in a\n> way that combines the standard line-by-line colorizing with the word-\n> by-word colorizing you get with --color-words.\n\nI like this idea, also because Emacs ediff / ediff3 / emerge uses it,\nfrom what I understand under the name of 'refinement'.\n\n> \n> Pictures speak louder than words, so here are some to show what I mean:\n> \n> http://www.flickr.com/photos/wincent-colaiuta/sets/72157612877491482/\n>\n[...]\n\nThere was some discussion in this thread on how to do this, whether\nwith --refine / --color-chars we shoud ony highlight differences, or\nwhether for example use reverse (i.e. background green or background\nred), or other red / other green, or perhaps bold, or perhaps\nunderline to highlight regions in line which differ\n\n> - Meld: http://meld.sourceforge.net/meld_file1.png\n\nNot extremly good example, as it uses equivalent of context diff\nformat (-,+,!) with added, removed and _changed_ lines, and not\nunified diff format (only added / removed lines).\n\n> Would people be interested in seeing this feature go in? [...]\n\n+1 from me\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}