Re: gitweb / cg-export

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: gitweb / cg-export

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:37

"Aneesh Kumar K.V" [off-list ref] writes:
How about the below on top of latest git

-aneesh
This looks Ok (except "$project" needs to be shell quoted on the
pipe-open line and possibly in the URL; there may be some other
minor details I missed).  It needs to be protected by elective,
opt-in configuration variable, similarly to how "blame" is done,
since I suspect this would be rather expensive.
quoted hunk
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 37a6284..b9b522a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -175,6 +175,7 @@ my %actions = (
 	"tag" => \&git_tag,
 	"tags" => \&git_tags,
 	"tree" => \&git_tree,
+	"snapshot" => \&git_snapshot,
 );
 
 $action = 'summary' if (!defined($action));
@@ -1334,6 +1335,7 @@ sub git_shortlog_body {
 		      "<td class=\"link\">" .
 		      $cgi->a({-href => href(action=>"commit", hash=>$commit)}, "commit") . " | " .
 		      $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff") .
+		      " | " .$cgi->a({-href => "$my_uri/$project.tar.gz?" . esc_param("p=$project;a=snapshot;h=$commit")}, "snapshot") .
 		      "</td>\n" .
 		      "</tr>\n";
 	}
@@ -2097,6 +2099,21 @@ sub git_tree {
 	git_footer_html();
 }
 
+sub git_snapshot {
+	if (!defined $hash) {
+		$hash = git_get_head_hash($project);
+	}
+	print $cgi->header(-type=>'application/x-tar',
+			  -Content-Encoding=>'x-gzip', -status=> '200 OK');
+	open my $fd, "-|", "$GIT tar-tree $hash $project | gzip -c9" or die_error(undef, "Execute git-tar-tree failed.");
+	binmode STDOUT, ':raw';
+	print <$fd>;
+	binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
+	close $fd;
+
+
+}
+
 sub git_log {
 	my $head = git_get_head_hash($project);
 	if (!defined $hash) {

gitweb: Support for snapshots in gitweb

From: Aneesh Kumar K.V <hidden>
Date: 2016-06-15 22:42:37

(no body)

Re: gitweb: Support for snapshots in gitweb

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:42:37

Aneesh Kumar K.V wrote:
+       print $cgi->header(-type=>'application/x-tar', -Content-Encoding=>'x-gzip',
+               '-content-disposition' => "inline; filename=\"$project.tar.gz\"",
+               -status=> '200 OK');
Wouldn't it be better to put $hash somewhere in the name?

And please remember that $project can contain slashes, so it should be processed
(only basename of $project, perhaps).

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help