[RFC] Line diff fragments, custom colour markers and word change highlighting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am using git to track various online stories and use it to keep a
history of any changes I make as I proofread them. The idea is that I
can then send this to the author for approval, so they can update the
stories their side and post updates.

At the moment, I am manually editing the output of git diff to produce
the desired output. I intend on modifying git to get it to produce the
output in a format that I am interested in so that I don't have to
edit it by hand.

The purpose of this RFC is to outline the changes I intend to make
(while still providing the existing behaviour) and see if it is useful
to go into the main git repository once I have implemented it:

(1) Line diff fragments

Taking the Lorum ipsum text as an example, if there is a typo in one
of the paragraphs then `git diff` will render the whole paragraph.
This is useful for machine processing, but not necessarily useful for
human readers. I have been cutting out everything but the paragraph
where the error is located, but a limit to X characters or word blocks
would also work. For example, showing:

$ git diff -U0 --fragment
- ... consectetur adipiscing elot. Proin interdum leo quis elit. ...
+ ... consectetur adipiscing elit. Proin interdum leo quis elit. ...

(2) Word change highlighting

Provide an option to allow the colour format to highlight just the
words that have changed and not the whole line. There have already
been some discussions on this ("git diff colorization idea"). So:

$ git diff -U0 --fragment --color-words
- ... consectetur adipiscing <red>elot</red>. Proin interdum leo quis elit. ...
+ ... consectetur adipiscing <green>elit</green>. Proin interdum leo
quis elit. ...

(3) Custom coloured diff markers

When performing a diff, you can get it to highlight the output of a
diff using terminal colour markers that will be rendered correctly if
your terminal supports processing them. This is great if you are
viewing the diff from a terminal, but if you are pasting it to another
media (forum, web page, etc) the colour information is lost.

It would be useful here to change the strings being written out to
denote colour, allowing you to generate HTML/CSS or forum/wiki markup
depending on context.

This could also help the git-web and git-gui tools that colour diff content.

I am not sure how this would work via command-line. If the output was
in a form that was easy to pipe through sed I would be happy. For
example:

$ git diff -U0 --fragment --color-words --color-markers
- ... consectetur adipiscing <red>elot</red>. Proin interdum leo quis elit. ...
+ ... consectetur adipiscing <green>elit</green>. Proin interdum leo
quis elit. ...

where <red> and the like are actually outputted and not there to
represent the terminal colour marker instruction character sequences.

Thoughts? Comments?

- Reece
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux