Re: [PATCH 3/8] gitweb: Move HTML-formatting diff line back to process_diff_line()

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

 



Michał Kiedrowicz <michal.kiedrowicz@xxxxxxxxx> writes:

> Commit 6ba1eb51b (gitweb: Add a feature to show side-by-side diff,
> 2011-10-31) for no special reason moved wrapping diff line in <div> out
> of format_diff_line(). Bring back old behavior.
> 
> This simplifies code in git_patchset_body() and keeps formatting of a
> diff line in one place.
> 
> The more long-term purpose of this patch is to move formatting diff
> lines down to print_diff_chunk(), to allow processing lines without
> HTML-formatting.
> 
> This is just a refactoring patch. It's not meant to change gitweb
> output.

Gah, I don't remember why we ended with change in behavior when adding
side-by-side diff support to gitweb.
 
> Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@xxxxxxxxx>

  Acked-by: Jakub Narębski <jnareb@xxxxxxxxx>

> ---
>  gitweb/gitweb.perl |   15 ++++++++-------
>  1 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index ed63261..d2f75c4 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -2332,14 +2332,18 @@ sub process_diff_line {
>  
>  	if ($from && $to && $line =~ m/^\@{2} /) {
>  		$line = format_unidiff_chunk_header($line, $from, $to);
> -		return $diff_class, $line;
>  
>  	} elsif ($from && $to && $line =~ m/^\@{3}/) {
>  		$line = format_cc_diff_chunk_header($line, $from, $to);
> -		return $diff_class, $line;
> -
> +	} else {
> +		$line = esc_html($line, -nbsp=>1);
>  	}
> -	return $diff_class, esc_html($line, -nbsp=>1);
> +
> +	my $diff_classes = "diff";
> +	$diff_classes .= " $diff_class" if ($diff_class);
> +	$line = "<div class=\"$diff_classes\">$line</div>\n";
> +
> +	return $diff_class, $line;
>  }
>  
>  # Generates undef or something like "_snapshot_" or "snapshot (_tbz2_ _zip_)",
> @@ -5104,9 +5108,6 @@ sub git_patchset_body {
>  			next PATCH if ($patch_line =~ m/^diff /);
>  
>  			my ($class, $line) = process_diff_line($patch_line, \%from, \%to);
> -			my $diff_classes = "diff";
> -			$diff_classes .= " $class" if ($class);
> -			$line = "<div class=\"$diff_classes\">$line</div>\n";
>  
>  			if ($class eq 'chunk_header') {
>  				print_diff_chunk($diff_style, $is_combined, @chunk);
> -- 
> 1.7.3.4
> 

-- 
Jakub Narębski

--
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]