{"thread":{"id":"17466","subject":"[RFC] Line diff fragments, custom colour markers and word change highlighting","startedAt":"2009-01-30T20:44:26Z","lastAt":"2009-01-31T06:57:42Z","messageCount":2,"participants":["Reece Dunn","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"102646","messageId":"3f4fd2640901301244s34d94e0fka00ce2eb6f6bef48@mail.gmail.com","threadId":"17466","inReplyTo":null,"subject":"[RFC] Line diff fragments, custom colour markers and word change highlighting","fromName":"Reece Dunn","fromEmail":"msclrhd@googlemail.com","sentAt":"2009-01-30T20:44:26Z","receivedAt":"2009-01-30T20:44:26Z","isPatch":false,"sender":{"key":"msclrhd@googlemail.com","avatar":null},"body":"Hi,\n\nI am using git to track various online stories and use it to keep a\nhistory of any changes I make as I proofread them. The idea is that I\ncan then send this to the author for approval, so they can update the\nstories their side and post updates.\n\nAt the moment, I am manually editing the output of git diff to produce\nthe desired output. I intend on modifying git to get it to produce the\noutput in a format that I am interested in so that I don't have to\nedit it by hand.\n\nThe purpose of this RFC is to outline the changes I intend to make\n(while still providing the existing behaviour) and see if it is useful\nto go into the main git repository once I have implemented it:\n\n(1) Line diff fragments\n\nTaking the Lorum ipsum text as an example, if there is a typo in one\nof the paragraphs then `git diff` will render the whole paragraph.\nThis is useful for machine processing, but not necessarily useful for\nhuman readers. I have been cutting out everything but the paragraph\nwhere the error is located, but a limit to X characters or word blocks\nwould also work. For example, showing:\n\n$ git diff -U0 --fragment\n- ... consectetur adipiscing elot. Proin interdum leo quis elit. ...\n+ ... consectetur adipiscing elit. Proin interdum leo quis elit. ...\n\n(2) Word change highlighting\n\nProvide an option to allow the colour format to highlight just the\nwords that have changed and not the whole line. There have already\nbeen some discussions on this (\"git diff colorization idea\"). So:\n\n$ git diff -U0 --fragment --color-words\n- ... consectetur adipiscing <red>elot</red>. Proin interdum leo quis elit. ...\n+ ... consectetur adipiscing <green>elit</green>. Proin interdum leo\nquis elit. ...\n\n(3) Custom coloured diff markers\n\nWhen performing a diff, you can get it to highlight the output of a\ndiff using terminal colour markers that will be rendered correctly if\nyour terminal supports processing them. This is great if you are\nviewing the diff from a terminal, but if you are pasting it to another\nmedia (forum, web page, etc) the colour information is lost.\n\nIt would be useful here to change the strings being written out to\ndenote colour, allowing you to generate HTML/CSS or forum/wiki markup\ndepending on context.\n\nThis could also help the git-web and git-gui tools that colour diff content.\n\nI am not sure how this would work via command-line. If the output was\nin a form that was easy to pipe through sed I would be happy. For\nexample:\n\n$ git diff -U0 --fragment --color-words --color-markers\n- ... consectetur adipiscing <red>elot</red>. Proin interdum leo quis elit. ...\n+ ... consectetur adipiscing <green>elit</green>. Proin interdum leo\nquis elit. ...\n\nwhere <red> and the like are actually outputted and not there to\nrepresent the terminal colour marker instruction character sequences.\n\nThoughts? Comments?\n\n- Reece\n"},{"id":"102680","messageId":"20090131065742.GA3033@coredump.intra.peff.net","threadId":"17466","inReplyTo":"3f4fd2640901301244s34d94e0fka00ce2eb6f6bef48@mail.gmail.com","subject":"Re: [RFC] Line diff fragments, custom colour markers and word change highlighting","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-01-31T06:57:42Z","receivedAt":"2009-01-31T06:57:42Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jan 30, 2009 at 08:44:26PM +0000, Reece Dunn wrote:\n\n> At the moment, I am manually editing the output of git diff to produce\n> the desired output. I intend on modifying git to get it to produce the\n> output in a format that I am interested in so that I don't have to\n> edit it by hand.\n\nHave you considered writing an external diff driver (see the description\nof GIT_EXTERNAL_DIFF in git(1))? That would be a good starting point for\nexperimenting if you want to use a totally different diff driver (but if\nyou are just making tweaks to git's diff code, then obviously that isn't\na good idea).\n\nYour RFCs look more like tweaks, but I wonder if there isn't already a\ngood external tool for doing these sorts of non-line-oriented diffs.\n\n-Peff\n"}]}