From 73c9083f52ac918b530c51887bbf5fd0a1119b4c Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 26 Aug 2006 12:33:17 +0200 Subject: [PATCH 1/4] gitweb: Remove workaround for git-diff bug fixed in f82cd3c Remove workaround in git_blobdiff for error in git-diff (showing reversed diff for diff of blobs), corrected in commit f82cd3c Fix "git diff blob1 blob2" showing the diff in reverse. which is post 1.4.2-rc2 commit. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index e00a6ed6e0..5d321e9b3b 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2834,8 +2834,7 @@ sub git_blobdiff { } # open patch output - #open $fd, "-|", $GIT, "diff", '-p', $hash_parent, $hash - open $fd, "-|", $GIT, "diff", '-p', $hash, $hash_parent + open $fd, "-|", $GIT, "diff", '-p', $hash_parent, $hash or die_error(undef, "Open git-diff failed"); } else { die_error('404 Not Found', "Missing one of the blob diff parameters") From 17848fc67cf466b805f35608230f4df898943ec1 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 26 Aug 2006 19:14:22 +0200 Subject: [PATCH 2/4] gitweb: Improve comments about gitweb features configuration Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 5d321e9b3b..2db99c3600 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -67,9 +67,16 @@ our $mimetypes_file = undef; # You define site-wide feature defaults here; override them with # $GITWEB_CONFIG as necessary. our %feature = ( - # feature => {'sub' => feature-sub, 'override' => allow-override, 'default' => [ default options...] - # if feature is overridable, feature-sub will be called with default options; - # return value indicates if to enable specified feature + # feature => { + # 'sub' => feature-sub (subroutine), + # 'override' => allow-override (boolean), + # 'default' => [ default options...] (array reference)} + # + # if feature is overridable (it means that allow-override has true value, + # then feature-sub will be called with default options as parameters; + # return value of feature-sub indicates if to enable specified feature + # + # use gitweb_check_feature() to check if is enabled 'blame' => { 'sub' => \&feature_blame, @@ -95,9 +102,9 @@ sub gitweb_check_feature { } # To enable system wide have in $GITWEB_CONFIG -# $feature{'blame'}{'default'} = [1]; -# To have project specific config enable override in $GITWEB_CONFIG -# $feature{'blame'}{'override'} = 1; +# $feature{'blame'}{'default'} = [1]; +# To have project specific config enable override in $GITWEB_CONFIG +# $feature{'blame'}{'override'} = 1; # and in project config gitweb.blame = 0|1; sub feature_blame { @@ -113,9 +120,9 @@ sub feature_blame { } # To disable system wide have in $GITWEB_CONFIG -# $feature{'snapshot'}{'default'} = [undef]; -# To have project specific config enable override in $GITWEB_CONFIG -# $feature{'blame'}{'override'} = 1; +# $feature{'snapshot'}{'default'} = [undef]; +# To have project specific config enable override in $GITWEB_CONFIG +# $feature{'blame'}{'override'} = 1; # and in project config gitweb.snapshot = none|gzip|bzip2 sub feature_snapshot { From f2e73302994b6072e556df1af998c0afd643e833 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 26 Aug 2006 19:14:25 +0200 Subject: [PATCH 3/4] gitweb: blobs defined by non-textual hash ids can be cached Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 2db99c3600..0df59af821 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2363,6 +2363,12 @@ sub git_heads { } sub git_blob_plain { + # blobs defined by non-textual hash id's can be cached + my $expires; + if ($hash =~ m/^[0-9a-fA-F]{40}$/) { + $expires = "+1d"; + } + if (!defined $hash) { if (defined $file_name) { my $base = $hash_base || git_get_head_hash($project); @@ -2386,8 +2392,10 @@ sub git_blob_plain { $save_as .= '.txt'; } - print $cgi->header(-type => "$type", - -content_disposition => "inline; filename=\"$save_as\""); + print $cgi->header( + -type => "$type", + -expires=>$expires, + -content_disposition => "inline; filename=\"$save_as\""); undef $/; binmode STDOUT, ':raw'; print <$fd>; @@ -2397,6 +2405,12 @@ sub git_blob_plain { } sub git_blob { + # blobs defined by non-textual hash id's can be cached + my $expires; + if ($hash =~ m/^[0-9a-fA-F]{40}$/) { + $expires = "+1d"; + } + if (!defined $hash) { if (defined $file_name) { my $base = $hash_base || git_get_head_hash($project); @@ -2414,7 +2428,7 @@ sub git_blob { close $fd; return git_blob_plain($mimetype); } - git_header_html(); + git_header_html(undef, $expires); my $formats_nav = ''; if (defined $hash_base && (my %co = parse_commit($hash_base))) { if (defined $file_name) { From 090525541ffd3f52867d5d26de5e02ce4998460b Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sat, 26 Aug 2006 23:33:58 +0200 Subject: [PATCH 4/4] gitweb: Fix typo in git_difftree_body Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 0df59af821..ba5024af14 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1556,7 +1556,7 @@ sub git_difftree_body { "blob") . " | " . $cgi->a({-href => href(action=>"history", hash_base=>$parent, - file_name=>$diff{'file'})},\ + file_name=>$diff{'file'})}, "history") . "\n";