git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 7/8] gitweb: Highlight interesting parts of diff

From
Michal Kiedrowicz <michal.kiedrowicz@gmail.com>
Date
Apr 5, 2012, 06:25 UTC
Message-ID
<20120405082557.7223ff6e@mkiedrowicz.ivo.pl>
In-Reply-To
<1333569433-3245-8-git-send-email-michal.kiedrowicz@gmail.com>
Michał Kiedrowicz <michal.kiedrowicz@gmail.com> wrote:
Show 22 quoted lines
> Reading diff output is sometimes very hard, even if it's colored,
> especially if lines differ only in few characters.  This is often true
> when a commit fixes a typo or renames some variables or functions.
> 
> This commit teaches gitweb to highlight characters that are different
> between old and new line with a light green/red background.  This
> should work in the similar manner as in Trac or GitHub.
> 
> The algorithm that compares lines is based on contrib/diff-highlight.
> Basically, it works by determining common prefix/suffix of
> corresponding lines and highlightning only the middle part of lines.
> For more information, see contrib/diff-highlight/README.
> 
> Combined diffs are not supported but a following commit will change
> it.
> 
> Since we need to pass esc_html()'ed or esc_html_hl_regions()'ed lines
> to format_diff_lines(), so it was taught to accept preformatted lines
> passed as a reference.
> 
> Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
> Acked-by: Jakub Narębski <jnareb@gmail.com>
Junio,

can you please fixup this patch? I just noticed "chomp $rem, $add" breaks the testsuite.

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e4351fe..961fbdc 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -5067,7 +5067,8 @@ sub format_rem_add_lines_pair {

        # We need to untabify lines before split()'ing them;
        # otherwise offsets would be invalid.
-       chomp $rem, $add;
+       chomp $rem;
+       chomp $add;
        $rem = untabify($rem);
        $add = untabify($add);
Previous: Michał KiedrowiczNext: Michał Kiedrowicz
Message 18 of 19 in “Highlight interesting parts of diff”
  1. 0/8 Highlight interesting parts of diffMichał Kiedrowicz, Apr 4, 2012
  2. 1/8 gitweb: Use descriptive names in esc_html_hl_regions()Michał Kiedrowicz, Apr 4, 2012
  3. Junio C HamanoApr 4, 2012
  4. Michal KiedrowiczApr 5, 2012
  5. 2/8 gitweb: esc_html_hl_regions(): Don't create empty <span> elementsMichał Kiedrowicz, Apr 4, 2012
  6. 3/8 gitweb: Pass esc_html_hl_regions() options to esc_html()Michał Kiedrowicz, Apr 4, 2012
  7. 4/8 gitweb: Extract print_sidebyside_diff_lines()Michał Kiedrowicz, Apr 4, 2012
  8. Junio C HamanoApr 4, 2012
  9. Jakub NarebskiApr 4, 2012
  10. Michal KiedrowiczApr 5, 2012
  11. Jakub NarebskiApr 5, 2012
  12. Michal KiedrowiczApr 6, 2012
  13. 5/8 gitweb: Use print_diff_chunk() for both side-by-side and inline diffsMichał Kiedrowicz, Apr 4, 2012
  14. Jakub NarebskiApr 5, 2012
  15. Michal KiedrowiczApr 6, 2012
  16. 6/8 gitweb: Push formatting diff lines to print_diff_chunk()Michał Kiedrowicz, Apr 4, 2012
  17. 7/8 gitweb: Highlight interesting parts of diffMichał Kiedrowicz, Apr 4, 2012
  18. Michal KiedrowiczApr 5, 2012
  19. 8/8 gitweb: Refinement highlightning in combined diffsMichał Kiedrowicz, Apr 4, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.