From: Jakub Narebski Date: Fri, 21 Sep 2007 21:39:49 GMT Subject: [PATCH 4/5] gitweb: Always set 'from_file' and 'to_file' in parse_difftree_raw_line Message-ID: <8fe92b430709211439v3c826dddw83e593d655bc6124@mail.gmail.com> Always set 'from_file' and 'to_file' keys when parsing raw diff output format line, even if filename didn't change (file was not renamed). This allows for less code (and no problems with file named '0'); use this. Signed-off-by: Jakub Narebski --- This simplifies code a bit _and_ fortifies gitweb against filenames like '0' (although it does remove _fragments_ of lines, not lines themselves, so it is not visible in diffstat). gitweb/gitweb.perl | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) From 9753f8b6a67239a4ed1ad5489965db37f7cbea89 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Thu, 13 Sep 2007 21:57:03 +0200 Subject: [PATCH 4/5] gitweb: Always set 'from_file' and 'to_file' in parse_difftree_raw_line Always set 'from_file' and 'to_file' keys when parsing raw diff output format line, even if filename didn't change (file was not renamed). This allows for less code (and no problems with file named '0'); use this. Signed-off-by: Jakub Narebski --- This simplifies code a bit _and_ fortifies gitweb against filenames like '0' (although it does remove _fragments_ of lines, not lines themselves, so it is not visible in diffstat). gitweb/gitweb.perl | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 1b5642a..6c79a95 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1968,7 +1968,7 @@ sub parse_difftree_raw_line { if ($res{'status'} eq 'R' || $res{'status'} eq 'C') { # renamed or copied ($res{'from_file'}, $res{'to_file'}) = map { unquote($_) } split("\t", $7); } else { - $res{'file'} = unquote($7); + $res{'from_file'} = $res{'to_file'} = $res{'file'} = unquote($7); } } # '::100755 100755 100755 60e79ca1b01bc8b057abe17ddab484699a7f5fdb 94067cc5f73388f33722d52ae02f44692bc07490 94067cc5f73388f33722d52ae02f44692bc07490 MR git-gui/git-gui.sh' @@ -2035,7 +2035,10 @@ sub parse_from_to_diffinfo { fill_from_file_info($diffinfo, @parents) unless exists $diffinfo->{'from_file'}; for (my $i = 0; $i < $diffinfo->{'nparents'}; $i++) { - $from->{'file'}[$i] = $diffinfo->{'from_file'}[$i] || $diffinfo->{'to_file'}; + $from->{'file'}[$i] = + defined $diffinfo->{'from_file'}[$i] ? + $diffinfo->{'from_file'}[$i] : + $diffinfo->{'to_file'}; if ($diffinfo->{'status'}[$i] ne "A") { # not new (added) file $from->{'href'}[$i] = href(action=>"blob", hash_base=>$parents[$i], @@ -2047,7 +2050,7 @@ sub parse_from_to_diffinfo { } } else { # ordinary (not combined) diff - $from->{'file'} = $diffinfo->{'from_file'} || $diffinfo->{'file'}; + $from->{'file'} = $diffinfo->{'from_file'}; if ($diffinfo->{'status'} ne "A") { # not new (added) file $from->{'href'} = href(action=>"blob", hash_base=>$hash_parent, hash=>$diffinfo->{'from_id'}, @@ -2057,7 +2060,7 @@ sub parse_from_to_diffinfo { } } - $to->{'file'} = $diffinfo->{'to_file'} || $diffinfo->{'file'}; + $to->{'file'} = $diffinfo->{'to_file'}; if (!is_deleted($diffinfo)) { # file exists in result $to->{'href'} = href(action=>"blob", hash_base=>$hash, hash=>$diffinfo->{'to_id'}, @@ -2802,7 +2805,7 @@ sub is_patch_split { my ($diffinfo, $patchinfo) = @_; return defined $diffinfo && defined $patchinfo - && ($diffinfo->{'to_file'} || $diffinfo->{'file'}) eq $patchinfo->{'to_file'}; + && $diffinfo->{'to_file'} eq $patchinfo->{'to_file'}; } @@ -4637,8 +4640,8 @@ sub git_blobdiff { } %diffinfo = parse_difftree_raw_line($difftree[0]); - $file_parent ||= $diffinfo{'from_file'} || $file_name || $diffinfo{'file'}; - $file_name ||= $diffinfo{'to_file'} || $diffinfo{'file'}; + $file_parent ||= $diffinfo{'from_file'} || $file_name; + $file_name ||= $diffinfo{'to_file'}; $hash_parent ||= $diffinfo{'from_id'}; $hash ||= $diffinfo{'to_id'}; -- 1.5.3