Skip to content

Commit b54dc9f

Browse files
committed
gitweb: do not run "git diff" that is Porcelain
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. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 98171a0 commit b54dc9f

File tree

1 file changed

+3
-37
lines changed

1 file changed

+3
-37
lines changed

gitweb/gitweb.perl

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5285,43 +5285,9 @@ sub git_blobdiff {
52855285
or die_error(500, "Open git-diff-tree failed");
52865286
}
52875287

5288-
# old/legacy style URI
5289-
if (!%diffinfo && # if new style URI failed
5290-
defined $hash && defined $hash_parent) {
5291-
# fake git-diff-tree raw output
5292-
$diffinfo{'from_mode'} = $diffinfo{'to_mode'} = "blob";
5293-
$diffinfo{'from_id'} = $hash_parent;
5294-
$diffinfo{'to_id'} = $hash;
5295-
if (defined $file_name) {
5296-
if (defined $file_parent) {
5297-
$diffinfo{'status'} = '2';
5298-
$diffinfo{'from_file'} = $file_parent;
5299-
$diffinfo{'to_file'} = $file_name;
5300-
} else { # assume not renamed
5301-
$diffinfo{'status'} = '1';
5302-
$diffinfo{'from_file'} = $file_name;
5303-
$diffinfo{'to_file'} = $file_name;
5304-
}
5305-
} else { # no filename given
5306-
$diffinfo{'status'} = '2';
5307-
$diffinfo{'from_file'} = $hash_parent;
5308-
$diffinfo{'to_file'} = $hash;
5309-
}
5310-
5311-
# non-textual hash id's can be cached
5312-
if ($hash =~ m/^[0-9a-fA-F]{40}$/ &&
5313-
$hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
5314-
$expires = '+1d';
5315-
}
5316-
5317-
# open patch output
5318-
open $fd, "-|", git_cmd(), "diff", @diff_opts,
5319-
'-p', ($format eq 'html' ? "--full-index" : ()),
5320-
$hash_parent, $hash, "--"
5321-
or die_error(500, "Open git-diff failed");
5322-
} else {
5323-
die_error(400, "Missing one of the blob diff parameters")
5324-
unless %diffinfo;
5288+
# old/legacy style URI -- not generated anymore since 1.4.3.
5289+
if (!%diffinfo) {
5290+
die_error('404 Not Found', "Missing one of the blob diff parameters")
53255291
}
53265292

53275293
# header

0 commit comments

Comments
 (0)