{"thread":{"id":"8247","subject":"[PATCH] gitweb.perl - Optionally send archives as .zip files","startedAt":"2007-05-20T15:46:46Z","lastAt":"2007-05-23T22:09:16Z","messageCount":3,"participants":["Mark Levedahl","Petr Baudis","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"42721","messageId":"11796760064103-git-send-email-mdl123@verizon.net","threadId":"8247","inReplyTo":null,"subject":"[PATCH] gitweb.perl - Optionally send archives as .zip files","fromName":"Mark Levedahl","fromEmail":"mdl123@verizon.net","sentAt":"2007-05-20T15:46:46Z","receivedAt":"2007-05-20T15:46:46Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"git-archive already knows how to generate an archive as a tar or a zip\nfile, but gitweb did not. zip archvies are much more usable in a Windows\nenvironment due to native support and this patch allows a site admin the\noption to deliver zip rather than tar files. The selection is done by\ninserting\n\n$feature{'snapshot'}{'default'} = ['x-zip', 'zip', ''];\n\nin gitweb_config.perl.\n\nTar files remain the default option.\n\nSigned-off-by: Mark Levedahl <mdl123@verizon.net>\n---\n gitweb/gitweb.perl |   25 +++++++++++++++++--------\n 1 files changed, 17 insertions(+), 8 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 21864c6..273cad2 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -129,7 +129,7 @@ our %feature = (\n \t# $feature{'snapshot'}{'default'} = [undef];\n \t# To have project specific config enable override in $GITWEB_CONFIG\n \t# $feature{'snapshot'}{'override'} = 1;\n-\t# and in project config gitweb.snapshot = none|gzip|bzip2;\n+\t# and in project config gitweb.snapshot = none|gzip|bzip2|zip;\n \t'snapshot' => {\n \t\t'sub' => \\&feature_snapshot,\n \t\t'override' => 0,\n@@ -227,6 +227,8 @@ sub feature_snapshot {\n \t\treturn ('x-gzip', 'gz', 'gzip');\n \t} elsif ($val eq 'bzip2') {\n \t\treturn ('x-bzip2', 'bz2', 'bzip2');\n+\t} elsif ($val eq 'zip') {\n+\t\treturn ('x-zip', 'zip', '');\n \t} elsif ($val eq 'none') {\n \t\treturn ();\n \t}\n@@ -3912,19 +3914,26 @@ sub git_snapshot {\n \t\t$hash = git_get_head_hash($project);\n \t}\n\n-\tmy $filename = decode_utf8(basename($project)) . \"-$hash.tar.$suffix\";\n+\tmy $git = git_cmd_str();\n+\tmy $name = $project;\n+\t$name =~ s/\\047/\\047\\\\\\047\\047/g;\n+\tmy $filename = decode_utf8(basename($project));\n+\tmy $cmd;\n+\tif ($suffix eq 'zip') {\n+\t\t$filename .= \"-$hash.$suffix\";\n+\t\t$cmd = \"$git archive --format=zip --prefix=\\'$name\\'/ $hash\";\n+\t} else {\n+\t\t$filename .= \"-$hash.tar.$suffix\";\n+\t\t$cmd = \"$git archive --format=tar --prefix=\\'$name\\'/ $hash | $command\";\n+\t}\n\n \tprint $cgi->header(\n \t\t-type => \"application/$ctype\",\n \t\t-content_disposition => 'inline; filename=\"' . \"$filename\" . '\"',\n \t\t-status => '200 OK');\n\n-\tmy $git = git_cmd_str();\n-\tmy $name = $project;\n-\t$name =~ s/\\047/\\047\\\\\\047\\047/g;\n-\topen my $fd, \"-|\",\n-\t\t\"$git archive --format=tar --prefix=\\'$name\\'/ $hash | $command\"\n-\t\tor die_error(undef, \"Execute git-tar-tree failed\");\n+\topen my $fd, \"-|\", $cmd\n+\t\tor die_error(undef, \"Execute git-archive failed\");\n \tbinmode STDOUT, ':raw';\n \tprint <$fd>;\n \tbinmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi\n--\n1.5.2.rc3.95.gb3c7e\n"},{"id":"42974","messageId":"20070522122828.GJ4489@pasky.or.cz","threadId":"8247","inReplyTo":"11796760064103-git-send-email-mdl123@verizon.net","subject":"Re: [PATCH] gitweb.perl - Optionally send archives as .zip files","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2007-05-22T12:28:28Z","receivedAt":"2007-05-22T12:28:28Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":" Hi,\n\nOn Sun, May 20, 2007 at 05:46:46PM CEST, Mark Levedahl wrote:\n> git-archive already knows how to generate an archive as a tar or a zip\n> file, but gitweb did not. zip archvies are much more usable in a Windows\n> environment due to native support and this patch allows a site admin the\n> option to deliver zip rather than tar files. The selection is done by\n> inserting\n> \n> $feature{'snapshot'}{'default'} = ['x-zip', 'zip', ''];\n> \n> in gitweb_config.perl.\n> \n> Tar files remain the default option.\n> \n> Signed-off-by: Mark Levedahl <mdl123@verizon.net>\n\nAcked-by: Petr Baudis <pasky@suse.cz>\n\nMaybe the code should decide based on program value being 'zip' rather\nthan suffix value, but that's just dubious nit-picking.\n\n> @@ -3912,19 +3914,26 @@ sub git_snapshot {\n>  \t\t$hash = git_get_head_hash($project);\n>  \t}\n> \n> -\tmy $filename = decode_utf8(basename($project)) . \"-$hash.tar.$suffix\";\n> +\tmy $git = git_cmd_str();\n> +\tmy $name = $project;\n> +\t$name =~ s/\\047/\\047\\\\\\047\\047/g;\n\nBy the way, this really looks like an entry to our very own would-be\n\"git obfuscation of the month\" contest. Why did whoever made the code\nnot just write that ' there?  (I know it's been in the original code\ntoo.)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nEver try. Ever fail. No matter. // Try again. Fail again. Fail better.\n\t\t-- Samuel Beckett\n"},{"id":"43059","messageId":"7v3b1n19bn.fsf@assigned-by-dhcp.cox.net","threadId":"8247","inReplyTo":"20070522122828.GJ4489@pasky.or.cz","subject":"Re: [PATCH] gitweb.perl - Optionally send archives as .zip files","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-23T22:09:16Z","receivedAt":"2007-05-23T22:09:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n>  Hi,\n>\n> On Sun, May 20, 2007 at 05:46:46PM CEST, Mark Levedahl wrote:\n>> git-archive already knows how to generate an archive as a tar or a zip\n>> file, but gitweb did not. zip archvies are much more usable in a Windows\n>> environment due to native support and this patch allows a site admin the\n>> option to deliver zip rather than tar files. The selection is done by\n>> inserting\n>> \n>> $feature{'snapshot'}{'default'} = ['x-zip', 'zip', ''];\n>> \n>> in gitweb_config.perl.\n>> \n>> Tar files remain the default option.\n>> \n>> Signed-off-by: Mark Levedahl <mdl123@verizon.net>\n>\n> Acked-by: Petr Baudis <pasky@suse.cz>\n\nOk, will apply to 'master'.\n"}]}