]> Lady’s Gitweb - Gitweb/blobdiff - gitweb.perl
gitweb: Add parsing of raw combined diff format to parse_difftree_raw_line
[Gitweb] / gitweb.perl
index 47dc9e13e55b6b03ee3c3e18df1747d14c25fbf44ee94e8cc22c16e5cd23a79a..67a6b263501e3cc7077c72437254ce5166ec607101612807e2a94d720d378010 100755 (executable)
@@ -565,12 +565,6 @@ sub validate_refname {
        return $input;
 }
 
        return $input;
 }
 
-# very thin wrapper for decode("utf8", $str, Encode::FB_DEFAULT);
-sub to_utf8 {
-       my $str = shift;
-       return decode("utf8", $str, Encode::FB_DEFAULT);
-}
-
 # quote unsafe chars, but keep the slash, even when it's not
 # correct, but quoted slashes look too horrible in bookmarks
 sub esc_param {
 # quote unsafe chars, but keep the slash, even when it's not
 # correct, but quoted slashes look too horrible in bookmarks
 sub esc_param {
@@ -595,7 +589,7 @@ sub esc_html ($;%) {
        my $str = shift;
        my %opts = @_;
 
        my $str = shift;
        my %opts = @_;
 
-       $str = to_utf8($str);
+       $str = decode_utf8($str);
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
                $str =~ s/ / /g;
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
                $str =~ s/ / /g;
@@ -609,7 +603,7 @@ sub esc_path {
        my $str = shift;
        my %opts = @_;
 
        my $str = shift;
        my %opts = @_;
 
-       $str = to_utf8($str);
+       $str = decode_utf8($str);
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
                $str =~ s/ / /g;
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
                $str =~ s/ / /g;
@@ -892,7 +886,7 @@ sub format_subject_html {
 
        if (length($short) < length($long)) {
                return $cgi->a({-href => $href, -class => "list subject",
 
        if (length($short) < length($long)) {
                return $cgi->a({-href => $href, -class => "list subject",
-                               -title => to_utf8($long)},
+                               -title => decode_utf8($long)},
                       esc_html($short) . $extra);
        } else {
                return $cgi->a({-href => $href, -class => "list subject"},
                       esc_html($short) . $extra);
        } else {
                return $cgi->a({-href => $href, -class => "list subject"},
@@ -1127,7 +1121,7 @@ sub git_get_projects_list {
                        if (check_export_ok("$projectroot/$path")) {
                                my $pr = {
                                        path => $path,
                        if (check_export_ok("$projectroot/$path")) {
                                my $pr = {
                                        path => $path,
-                                       owner => to_utf8($owner),
+                                       owner => decode_utf8($owner),
                                };
                                push @list, $pr;
                                (my $forks_path = $path) =~ s/\.git$//;
                                };
                                push @list, $pr;
                                (my $forks_path = $path) =~ s/\.git$//;
@@ -1157,7 +1151,7 @@ sub git_get_project_owner {
                        $pr = unescape($pr);
                        $ow = unescape($ow);
                        if ($pr eq $project) {
                        $pr = unescape($pr);
                        $ow = unescape($ow);
                        if ($pr eq $project) {
-                               $owner = to_utf8($ow);
+                               $owner = decode_utf8($ow);
                                last;
                        }
                }
                                last;
                        }
                }
@@ -1502,6 +1496,17 @@ sub parse_difftree_raw_line {
                        $res{'file'} = unquote($7);
                }
        }
                        $res{'file'} = unquote($7);
                }
        }
+       # '::100755 100755 100755 60e79ca1b01bc8b057abe17ddab484699a7f5fdb 94067cc5f73388f33722d52ae02f44692bc07490 94067cc5f73388f33722d52ae02f44692bc07490 MR git-gui/git-gui.sh'
+       # combined diff (for merge commit)
+       elsif ($line =~ s/^(::+)((?:[0-7]{6} )+)((?:[0-9a-fA-F]{40} )+)([a-zA-Z]+)\t(.*)$//) {
+               $res{'nparents'}  = length($1);
+               $res{'from_mode'} = [ split(' ', $2) ];
+               $res{'to_mode'} = pop @{$res{'from_mode'}};
+               $res{'from_id'} = [ split(' ', $3) ];
+               $res{'to_id'} = pop @{$res{'from_id'}};
+               $res{'status'} = [ split('', $4) ];
+               $res{'to_file'} = unquote($5);
+       }
        # 'c512b523472485aef4fff9e57b229d9d243c967f'
        elsif ($line =~ m/^([0-9a-fA-F]{40})$/) {
                $res{'commit'} = $1;
        # 'c512b523472485aef4fff9e57b229d9d243c967f'
        elsif ($line =~ m/^([0-9a-fA-F]{40})$/) {
                $res{'commit'} = $1;
@@ -1631,7 +1636,7 @@ sub get_file_owner {
        }
        my $owner = $gcos;
        $owner =~ s/[,;].*$//;
        }
        my $owner = $gcos;
        $owner =~ s/[,;].*$//;
-       return to_utf8($owner);
+       return decode_utf8($owner);
 }
 
 ## ......................................................................
 }
 
 ## ......................................................................
@@ -1714,7 +1719,7 @@ sub git_header_html {
 
        my $title = "$site_name";
        if (defined $project) {
 
        my $title = "$site_name";
        if (defined $project) {
-               $title .= " - " . to_utf8($project);
+               $title .= " - " . decode_utf8($project);
                if (defined $action) {
                        $title .= "/$action";
                        if (defined $file_name) {
                if (defined $action) {
                        $title .= "/$action";
                        if (defined $file_name) {
@@ -1987,7 +1992,7 @@ sub git_print_page_path {
 
        print "<div class=\"page_path\">";
        print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
 
        print "<div class=\"page_path\">";
        print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
-                     -title => 'tree root'}, to_utf8("[$project]"));
+                     -title => 'tree root'}, decode_utf8("[$project]"));
        print " / ";
        if (defined $name) {
                my @dirname = split '/', $name;
        print " / ";
        if (defined $name) {
                my @dirname = split '/', $name;
@@ -2399,6 +2404,7 @@ sub git_patchset_body {
        my ($fd, $difftree, $hash, $hash_parent) = @_;
 
        my $patch_idx = 0;
        my ($fd, $difftree, $hash, $hash_parent) = @_;
 
        my $patch_idx = 0;
+       my $patch_number = 0;
        my $patch_line;
        my $diffinfo;
        my (%from, %to);
        my $patch_line;
        my $diffinfo;
        my (%from, %to);
@@ -2420,6 +2426,7 @@ sub git_patchset_body {
                # git diff header
                #assert($patch_line =~ m/^diff /) if DEBUG;
                #assert($patch_line !~ m!$/$!) if DEBUG; # is chomp-ed
                # git diff header
                #assert($patch_line =~ m/^diff /) if DEBUG;
                #assert($patch_line !~ m!$/$!) if DEBUG; # is chomp-ed
+               $patch_number++;
                push @diff_header, $patch_line;
 
                # extended diff header
                push @diff_header, $patch_line;
 
                # extended diff header
@@ -2582,6 +2589,7 @@ sub git_patchset_body {
        } continue {
                print "</div>\n"; # class="patch"
        }
        } continue {
                print "</div>\n"; # class="patch"
        }
+       print "<div class=\"diff nodifferences\">No differences found</div>\n" if (!$patch_number);
 
        print "</div>\n"; # class="patchset"
 }
 
        print "</div>\n"; # class="patchset"
 }
@@ -2602,7 +2610,7 @@ sub git_project_list_body {
                ($pr->{'age'}, $pr->{'age_string'}) = @aa;
                if (!defined $pr->{'descr'}) {
                        my $descr = git_get_project_description($pr->{'path'}) || "";
                ($pr->{'age'}, $pr->{'age_string'}) = @aa;
                if (!defined $pr->{'descr'}) {
                        my $descr = git_get_project_description($pr->{'path'}) || "";
-                       $pr->{'descr_long'} = to_utf8($descr);
+                       $pr->{'descr_long'} = decode_utf8($descr);
                        $pr->{'descr'} = chop_str($descr, 25, 5);
                }
                if (!defined $pr->{'owner'}) {
                        $pr->{'descr'} = chop_str($descr, 25, 5);
                }
                if (!defined $pr->{'owner'}) {
@@ -3634,7 +3642,7 @@ sub git_snapshot {
                $hash = git_get_head_hash($project);
        }
 
                $hash = git_get_head_hash($project);
        }
 
-       my $filename = to_utf8(basename($project)) . "-$hash.tar.$suffix";
+       my $filename = decode_utf8(basename($project)) . "-$hash.tar.$suffix";
 
        print $cgi->header(
                -type => "application/$ctype",
 
        print $cgi->header(
                -type => "application/$ctype",
This page took 0.203456 seconds and 4 git commands to generate.