<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/contrib/diff-highlight, branch v2.16.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.16.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.16.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2017-09-06T03:56:26Z</updated>
<entry>
<title>diff-highlight: add clean target to Makefile</title>
<updated>2017-09-06T03:56:26Z</updated>
<author>
<name>Daniel Watkins</name>
<email>daniel@daniel-watkins.co.uk</email>
</author>
<published>2017-08-29T11:23:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=74f1bd912be9a6c72a2fe23a3a336dec66f29d83'/>
<id>urn:sha1:74f1bd912be9a6c72a2fe23a3a336dec66f29d83</id>
<content type='text'>
Now that `make` produces a file, we should have a clean target to remove
it.

Signed-off-by: Daniel Watkins &lt;daniel@daniel-watkins.co.uk&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-highlight: split code into module</title>
<updated>2017-06-15T19:15:58Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-06-15T16:30:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0c977dbc8180892af42d7ab9235fd3e51d6c4078'/>
<id>urn:sha1:0c977dbc8180892af42d7ab9235fd3e51d6c4078</id>
<content type='text'>
The diff-so-fancy project is also written in perl, and most
of its users pipe diffs through both diff-highlight and
diff-so-fancy. It would be nice if this could be done in a
single script. So let's pull most of diff-highlight's code
into its own module which can be used by diff-so-fancy.

In addition, we'll abstract a few basic items like reading
from stdio so that a script using the module can do more
processing before or after diff-highlight handles the lines.
See the README update for more details.

One small downside is that the diff-highlight script must
now be built using the Makefile. There are ways around this,
but it quickly gets into perl arcana. Let's go with the
simple solution. As a bonus, our Makefile now respects the
PERL_PATH variable if it is set.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-highlight: avoid highlighting combined diffs</title>
<updated>2016-08-31T16:59:53Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-08-31T05:05:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3dbfe2b8ae94cbdae5f3d32581aedaa5510fdc87'/>
<id>urn:sha1:3dbfe2b8ae94cbdae5f3d32581aedaa5510fdc87</id>
<content type='text'>
The algorithm in diff-highlight only understands how to look
at two sides of a diff; it cannot correctly handle combined
diffs with multiple preimages. Often highlighting does not
trigger at all for these diffs because the line counts do
not match up.  E.g., if we see:

  - ours
   -theirs
  ++resolved

we would not bother highlighting; it naively looks like a
single line went away, and then a separate hunk added
another single line.

But of course there are exceptions. E.g., if the other side
deleted the line, we might see:

  - ours
  ++resolved

which looks like we dropped " ours" and added "+resolved".
This is only a small highlighting glitch (we highlight the
space and the "+" along with the content), but it's also the
tip of the iceberg. Even if we learned to find the true
content here (by noticing we are in a 3-way combined diff
and marking _two_ characters from the front of the line as
uninteresting), there are other more complicated cases where
we really do need to handle a 3-way hunk.

Let's just punt for now; we can recognize combined diffs by
the presence of extra "@" symbols in the hunk header, and
treat them as non-diff content.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-highlight: add multi-byte tests</title>
<updated>2016-08-31T16:58:43Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-08-31T05:03:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1b5290b125fca91f620aadbc1a5e3c559d4a5313'/>
<id>urn:sha1:1b5290b125fca91f620aadbc1a5e3c559d4a5313</id>
<content type='text'>
Now that we have a test suite for diff highlight, we can
show off the improvements from 8d00662 (diff-highlight: do
not split multibyte characters, 2015-04-03).

While we're at it, we can also add another case that
_doesn't_ work: combining code points are treated as their
own unit, which means that we may stick colors between them
and the character they are modifying (with the result that
the color is not shown in an xterm, though it's possible
that other terminals err the other way, and show the color
but not the accent).  There's no fix here, but let's
document it as a failure.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-highlight: ignore test cruft</title>
<updated>2016-08-31T16:58:27Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-08-31T05:02:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9f76e520027d1bbe675d44a951da6f0b3cc3b51e'/>
<id>urn:sha1:9f76e520027d1bbe675d44a951da6f0b3cc3b51e</id>
<content type='text'>
These are the same as in the normal t/.gitignore, with the
exception of ".prove", as our Makefile does not support it.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-highlight: add support for --graph output</title>
<updated>2016-08-29T19:20:50Z</updated>
<author>
<name>Brian Henderson</name>
<email>henderson.bj@gmail.com</email>
</author>
<published>2016-08-29T17:33:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7e4ffb4c1778c725db3db116f016ef2ad1c6d218'/>
<id>urn:sha1:7e4ffb4c1778c725db3db116f016ef2ad1c6d218</id>
<content type='text'>
Signed-off-by: Brian Henderson &lt;henderson.bj@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-highlight: add failing test for handling --graph output</title>
<updated>2016-08-29T19:20:18Z</updated>
<author>
<name>Brian Henderson</name>
<email>henderson.bj@gmail.com</email>
</author>
<published>2016-08-29T17:33:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=caf5ea707c2a412cdb61ef694678673b4cbec550'/>
<id>urn:sha1:caf5ea707c2a412cdb61ef694678673b4cbec550</id>
<content type='text'>
Signed-off-by: Brian Henderson &lt;henderson.bj@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-highlight: add some tests</title>
<updated>2016-08-29T19:18:50Z</updated>
<author>
<name>Brian Henderson</name>
<email>henderson.bj@gmail.com</email>
</author>
<published>2016-08-29T17:33:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=23b250ab0f041bba7af4ba8eb1a686f6850677a6'/>
<id>urn:sha1:23b250ab0f041bba7af4ba8eb1a686f6850677a6</id>
<content type='text'>
Signed-off-by: Brian Henderson &lt;henderson.bj@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/colors'</title>
<updated>2015-04-14T18:49:13Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-04-14T18:49:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7a1aa0c28876e044351e78d8b8ae6cdbb10b5dfe'/>
<id>urn:sha1:7a1aa0c28876e044351e78d8b8ae6cdbb10b5dfe</id>
<content type='text'>
"diff-highlight" (in contrib/) used to show byte-by-byte
differences, which meant that multi-byte characters can be chopped
in the middle.  It learned to pay attention to character boundaries
(assuming the UTF-8 payload).

* jk/colors:
  diff-highlight: do not split multibyte characters
</content>
</entry>
<entry>
<title>diff-highlight: do not split multibyte characters</title>
<updated>2015-04-04T20:03:45Z</updated>
<author>
<name>Kyle J. McKay</name>
<email>mackyle@gmail.com</email>
</author>
<published>2015-04-03T22:15:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8d00662d7d263448d90637ef6758fd2a0b526fec'/>
<id>urn:sha1:8d00662d7d263448d90637ef6758fd2a0b526fec</id>
<content type='text'>
When the input is UTF-8 and Perl is operating on bytes instead of
characters, a diff that changes one multibyte character to another
that shares an initial byte sequence will result in a broken diff
display as the common byte sequence prefix will be separated from
the rest of the bytes in the multibyte character.

For example, if a single line contains only the unicode character
U+C9C4 (encoded as UTF-8 0xEC, 0xA7, 0x84) and that line is then
changed to the unicode character U+C9C0 (encoded as UTF-8 0xEC,
0xA7, 0x80), when operating on bytes diff-highlight will show only
the single byte change from 0x84 to 0x80 thus creating invalid UTF-8
and a broken diff display.

Fix this by putting Perl into character mode when splitting the line
and then back into byte mode after the split is finished.

The utf8::xxx functions require Perl 5.8 so we require that as well.

Also, since we are mucking with code in the split_line function, we
change a '*' quantifier to a '+' quantifier when matching the $COLOR
expression which has the side effect of speeding everything up while
eliminating useless '' elements in the returned array.

Reported-by: Yi EungJun &lt;semtlenori@gmail.com&gt;
Signed-off-by: Kyle J. McKay &lt;mackyle@gmail.com&gt;
Acked-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
