git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* A failed attempt to integrate diff-highlight to the core
@ 2015-12-31 12:37 Nguyễn Thái Ngọc Duy
  2015-12-31 12:37 ` [PATCH 1/7] diff.c: keep all word diff structs together Nguyễn Thái Ngọc Duy
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2015-12-31 12:37 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

This is mostly for the record. The patches are not as important as the
result in this mail. But if you want to try out, you can.

If you don't know, the script diff-highlight in contrib can highlight
changes between two nearly identical lines, pointing out what
characters are different. It can improve readability a lot in certain
cases (e.g. when you wrap _() around strings).

I approached it differently. I took --color-words and reformatted its
output in unified diff format. So you'll see +/- lines like a normal
diff, but deleted and added words are also highlighted.

The idea seems to fit well into diff-words machinery. But the output
does not, especially in cases where there are many deleted/added words
in a chunk. It could look.. patchy, like somebody throwing colors on a
wall (especially when you do --highlight-words=.). You can try out and
see.  git-log works so you can see lots of diff.

I don't know, maybe the idea can be improved to have something closer
to diff-highlight. I suppose we can select similar lines and diff
them, instead of diff the entire chunk in one go. I might revisit it
at some point in future, but for now, it's a failure.

Nguyễn Thái Ngọc Duy (7):
  diff.c: keep all word diff structs together
  diff.c: refactor diff_words_append()
  diff --color-words: another special diff case
  diff.c: refactor fn_out_diff_words_write_helper()
  diff: unified diff with colored words, step 1, unified diff only
  diff.c: add new arguments to emit_line_0()
  diff --highlight-words: actually highlight words

 diff.c | 400 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 diff.h |   3 +-
 2 files changed, 363 insertions(+), 40 deletions(-)

-- 
2.3.0.rc1.137.g477eb31

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-12-31 12:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-31 12:37 A failed attempt to integrate diff-highlight to the core Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 1/7] diff.c: keep all word diff structs together Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 2/7] diff.c: refactor diff_words_append() Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 3/7] diff --color-words: another special diff case Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 4/7] diff.c: refactor fn_out_diff_words_write_helper() Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 5/7] diff: unified diff with colored words, step 1, unified diff only Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 6/7] diff.c: add new arguments to emit_line_0() Nguyễn Thái Ngọc Duy
2015-12-31 12:37 ` [PATCH 7/7] diff --highlight-words: actually highlight words Nguyễn Thái Ngọc Duy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).