git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar" <aneesh.kumar@gmail.com>
To: "Junio C Hamano" <junkio@cox.net>
Cc: "Luben Tuikov" <ltuikov@yahoo.com>,
	git@vger.kernel.org, "jakub narebski" <jnareb@gmail.com>
Subject: Re: [PATCH] gitweb: Support for snapshot
Date: Sat, 19 Aug 2006 13:40:31 +0530	[thread overview]
Message-ID: <cc723f590608190110t68e6de8etbf6b5b002fd83ca1@mail.gmail.com> (raw)
In-Reply-To: <7v64gp7prk.fsf@assigned-by-dhcp.cox.net>

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

On 8/19/06, Junio C Hamano <junkio@cox.net> wrote:
> Luben Tuikov <ltuikov@yahoo.com> writes:
>
> > --- "Aneesh Kumar K.V" <aneesh.kumar@gmail.com> wrote:
> >> This adds snapshort support in gitweb. To enable one need to
> >> set gitweb.snapshot = true in the config file.
> >
> > Could you use bzip2?  It generates smaller files (better compression),
> > which is a good thing when downloading over a network.
>
> Because bzip2 is heavier on the server than gzip is (and gzip is
> heavier than "gzip -1" is), there obviously is a trade-off.  We
> would want it to be configurable just like blame and snapshot
> itself.
>
> Maybe:
>
>         config.snapshot = no | yes | gzip | bzip2 ...
>
> By the way, I think it is a mistake to use only $GIT_DIR/config
> to control these features.
>

I have coded this at

What should be the content-encoding in this case x-$snapshot ?

This is the untested diff that i have. Is this what we are looking for ?


-aneesh

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gitweb.diff --]
[-- Type: text/x-patch; name="gitweb.diff", Size: 2484 bytes --]

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f8d1036..6ad3141 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -67,6 +67,15 @@ # file to use for guessing MIME types be
 # (relative to the current git repository)
 our $mimetypes_file = undef;
 
+# don't enable snapshot support by default
+# possible values are no|gzip|bzip2|
+our $snapshot = "no";
+
+# this indicate whether the snapshot support can be overridden
+# by a project specific config.
+# possible values are yes|no
+our $snapshot_override = "no";
+
 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
 require $GITWEB_CONFIG if -e $GITWEB_CONFIG;
 
@@ -1397,7 +1406,7 @@ sub git_difftree_body {
 sub git_shortlog_body {
 	# uses global variable $project
 	my ($revlist, $from, $to, $refs, $extra) = @_;
-	my $have_snapshot = git_get_project_config_bool('snapshot');
+	my ($have_snapshot, $snapshot_comp) = git_get_project_snapshot_config();
 	$from = 0 unless defined $from;
 	$to = $#{$revlist} if (!defined $to || $#{$revlist} < $to);
 
@@ -2200,13 +2209,14 @@ sub git_snapshot {
 	}
 
 	my $filename = basename($project) . "-$hash.tar.gz";
+	my ($have_snapshot, $snapshot_comp) = git_get_project_snapshot_config();
 
 	print $cgi->header(-type => 'application/x-tar',
-			-content-encoding => 'x-gzip',
+			-content-encoding => "x-$snapshot_comp",
 			'-content-disposition' => "inline; filename=\"$filename\"",
 			-status => '200 OK');
 
-	open my $fd, "-|", "$GIT tar-tree $hash \'$project\' | gzip" or
+	open my $fd, "-|", "$GIT tar-tree $hash \'$project\' | $snapshot_comp" or
 				die_error(undef, "Execute git-tar-tree failed.");
 	binmode STDOUT, ':raw';
 	print <$fd>;
@@ -2215,6 +2225,27 @@ sub git_snapshot {
 
 
 }
+sub git_get_project_snapshot_config()
+{
+	my $snap;
+
+	if ($snapshot =~ m/no/) {
+		return (0, undef);
+	}
+
+	if ($snapshot_override =~ m/no/) {
+		return (1, $snapshot);
+	}
+
+	$snap = git_get_project_config('snapshot');
+
+	if ($snap and $snap =~ m/no/) {
+		return (0, undef);
+	}
+	return (1, $snap);
+}
+
+}
 
 sub git_log {
 	my $head = git_get_head_hash($project);
@@ -2293,7 +2324,7 @@ sub git_commit {
 	}
 	my $refs = git_get_references();
 	my $ref = format_ref_marker($refs, $co{'id'});
-	my $have_snapshot = git_get_project_config_bool('snapshot');
+	my ($have_snapshot, $snapshot_comp) = git_get_project_snapshot_config();
 	my $formats_nav = '';
 	if (defined $file_name && defined $co{'parent'}) {
 		my $parent = $co{'parent'};

  parent reply	other threads:[~2006-08-19  8:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-17 15:29 gitweb: Support for snapshot Aneesh Kumar K.V
2006-08-18  5:06 ` [PATCH] " Aneesh Kumar K.V
2006-08-18 19:51   ` Luben Tuikov
2006-08-18 20:05     ` Timo Hirvonen
     [not found]     ` <7v64gp7prk.fsf@assigned-by-dhcp.cox.net>
2006-08-19  8:10       ` Aneesh Kumar [this message]
2006-08-19 10:51         ` Junio C Hamano
2006-08-19 11:09           ` Jakub Narebski
2006-08-19 11:13           ` Jakub Narebski
2006-08-19 11:58             ` Aneesh Kumar K.V
2006-08-19 13:56           ` Aneesh Kumar K.V
2006-08-19 14:22             ` Jakub Narebski
2006-08-19 16:17               ` Aneesh Kumar K.V
2006-08-19 16:26                 ` Aneesh Kumar K.V
2006-08-19 21:49               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc723f590608190110t68e6de8etbf6b5b002fd83ca1@mail.gmail.com \
    --to=aneesh.kumar@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=junkio@cox.net \
    --cc=ltuikov@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).