Skip to content

Commit

Permalink
gitweb: do not run "git diff" that is Porcelain
Browse files Browse the repository at this point in the history
Jakub says that legacy-style URI to view two blob differences are never
generated since 1.4.3.  This codepath runs "git diff" Porcelain from the
gitweb, which is a no-no.  It can trigger diff.external command that is
specified in the configuration file of the repository being viewed.

This patch applies to v1.5.4 and later.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Dec 17, 2008
1 parent 872354d commit dfff4b7
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -4809,43 +4809,9 @@ sub git_blobdiff {
or die_error(undef, "Open git-diff-tree failed");
}

# old/legacy style URI
if (!%diffinfo && # if new style URI failed
defined $hash && defined $hash_parent) {
# fake git-diff-tree raw output
$diffinfo{'from_mode'} = $diffinfo{'to_mode'} = "blob";
$diffinfo{'from_id'} = $hash_parent;
$diffinfo{'to_id'} = $hash;
if (defined $file_name) {
if (defined $file_parent) {
$diffinfo{'status'} = '2';
$diffinfo{'from_file'} = $file_parent;
$diffinfo{'to_file'} = $file_name;
} else { # assume not renamed
$diffinfo{'status'} = '1';
$diffinfo{'from_file'} = $file_name;
$diffinfo{'to_file'} = $file_name;
}
} else { # no filename given
$diffinfo{'status'} = '2';
$diffinfo{'from_file'} = $hash_parent;
$diffinfo{'to_file'} = $hash;
}

# non-textual hash id's can be cached
if ($hash =~ m/^[0-9a-fA-F]{40}$/ &&
$hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
$expires = '+1d';
}

# open patch output
open $fd, "-|", git_cmd(), "diff", @diff_opts,
'-p', ($format eq 'html' ? "--full-index" : ()),
$hash_parent, $hash, "--"
or die_error(undef, "Open git-diff failed");
} else {
# old/legacy style URI -- not generated anymore since 1.4.3.
if (!%diffinfo) {
die_error('404 Not Found', "Missing one of the blob diff parameters")
unless %diffinfo;
}

# header
Expand Down

0 comments on commit dfff4b7

Please sign in to comment.