{"thread":{"id":"28837","subject":"[PATCHv2] Add options to specify snapshot file name, prefix","startedAt":"2011-11-04T00:53:19Z","lastAt":"2011-11-05T09:18:22Z","messageCount":5,"participants":["Thomas Guyot-Sionnest","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"178806","messageId":"1320367999-24435-1-git-send-email-dermoth@aei.ca","threadId":"28837","inReplyTo":"1320302318-28315-1-git-send-email-dermoth@aei.ca","subject":"[PATCHv2] Add options to specify snapshot file name, prefix","fromName":"Thomas Guyot-Sionnest","fromEmail":"dermoth@aei.ca","sentAt":"2011-11-04T00:53:19Z","receivedAt":"2011-11-04T00:53:19Z","isPatch":false,"sender":{"key":"dermoth@aei.ca","avatar":null},"body":"commit b629275 implemented \"smart\" snapshot names and prefixes. I have\nscripts that used to rely on the old behaviour which allowed in some\ncases to have fixed prefix, and would require modifications to work with\nnewer Gitweb.\n\nThis patch adds two parameters for overriding the snapshot name and\nprefix, sn and sp respectively. For example, to get a snapshot\nnamed \"myproject.[suffix]\" with no prefix one can add this query string:\n  ?sn=myproject;sp=\n\nSigned-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>\n---\n gitweb/gitweb.perl |   12 +++++++++++-\n 1 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 4f0c3bd..9c91f01 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -756,6 +756,8 @@ our @cgi_param_mapping = (\n \tsearchtext => \"s\",\n \tsearchtype => \"st\",\n \tsnapshot_format => \"sf\",\n+\tsnapshot_name => \"sn\",\n+\tsnapshot_prefix => \"sp\",\n \textra_options => \"opt\",\n \tsearch_use_regexp => \"sr\",\n \tctag => \"by_tag\",\n@@ -6684,11 +6686,19 @@ sub git_snapshot {\n \t}\n \n \tmy ($name, $prefix) = snapshot_name($project, $hash);\n+\tif (defined($input_params{'snapshot_name'})) {\n+\t\t$name = $input_params{'snapshot_name'};\n+\t}\n+\tif (defined($input_params{'snapshot_prefix'})) {\n+\t\t$prefix = $input_params{'snapshot_prefix'};\n+\t} else {\n+\t\t$prefix .= '/';\n+\t}\n \tmy $filename = \"$name$known_snapshot_formats{$format}{'suffix'}\";\n \tmy $cmd = quote_command(\n \t\tgit_cmd(), 'archive',\n \t\t\"--format=$known_snapshot_formats{$format}{'format'}\",\n-\t\t\"--prefix=$prefix/\", $hash);\n+\t\t\"--prefix=$prefix\", $hash);\n \tif (exists $known_snapshot_formats{$format}{'compressor'}) {\n \t\t$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});\n \t}\n-- \n1.7.7.1\n"},{"id":"178837","messageId":"m3fwi350ou.fsf@localhost.localdomain","threadId":"28837","inReplyTo":"1320367999-24435-1-git-send-email-dermoth@aei.ca","subject":"Re: [PATCHv2] Add options to specify snapshot file name, prefix","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-11-04T16:10:16Z","receivedAt":"2011-11-04T16:10:16Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Thomas Guyot-Sionnest <dermoth@aei.ca> writes:\n\n> commit b629275 implemented \"smart\" snapshot names and prefixes. I have\n> scripts that used to rely on the old behaviour which allowed in some\n> cases to have fixed prefix, and would require modifications to work with\n> newer Gitweb.\n\nIf scripts use 'wget' or 'curl' you can always change the name of\nsaved file:\n\n  wget -O <file> ...\n  curl -o <file> ...\n\nIf downloaded snapshot is compressed tarfile, you can use\n--strip-components=1 to strip prefix.\n \n> This patch adds two parameters for overriding the snapshot name and\n> prefix, sn and sp respectively. For example, to get a snapshot\n> named \"myproject.[suffix]\" with no prefix one can add this query string:\n>   ?sn=myproject;sp=\n\nWould you need support for expandable parameters in both (a la\n'action' feature)?\n\n[...] \n> @@ -6684,11 +6686,19 @@ sub git_snapshot {\n>  \t}\n>  \n>  \tmy ($name, $prefix) = snapshot_name($project, $hash);\n> +\tif (defined($input_params{'snapshot_name'})) {\n> +\t\t$name = $input_params{'snapshot_name'};\n> +\t}\n> +\tif (defined($input_params{'snapshot_prefix'})) {\n> +\t\t$prefix = $input_params{'snapshot_prefix'};\n> +\t} else {\n> +\t\t$prefix .= '/';\n> +\t}\n>  \tmy $filename = \"$name$known_snapshot_formats{$format}{'suffix'}\";\n>  \tmy $cmd = quote_command(\n>  \t\tgit_cmd(), 'archive',\n>  \t\t\"--format=$known_snapshot_formats{$format}{'format'}\",\n> -\t\t\"--prefix=$prefix/\", $hash);\n> +\t\t\"--prefix=$prefix\", $hash);\n>  \tif (exists $known_snapshot_formats{$format}{'compressor'}) {\n>  \t\t$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});\n>  \t}\n\nI wonder if you really want to allow prefix which do not end in '/'\n(which would be suprising, isn't it), or just allow empty prefix too.\n\nFor example\n\n  @@ -6684,11 +6686,19 @@ sub git_snapshot {\n   \t}\n   \n   \tmy ($name, $prefix) = snapshot_name($project, $hash);\n  +\tif (defined($input_params{'snapshot_name'})) {\n  +\t\t$name = $input_params{'snapshot_name'};\n  +\t}\n  +\tif (defined($input_params{'snapshot_prefix'})) {\n  +\t\t$prefix = $input_params{'snapshot_prefix'};\n  +\t}\n   \tmy $filename = \"$name$known_snapshot_formats{$format}{'suffix'}\";\n   \tmy $cmd = quote_command(\n   \t\tgit_cmd(), 'archive',\n   \t\t\"--format=$known_snapshot_formats{$format}{'format'}\",\n  -\t\t\"--prefix=$prefix/\", $hash);\n  +\t\t($prefix eq \"\" ? () : \"--prefix=$prefix\"), $hash);\n   \tif (exists $known_snapshot_formats{$format}{'compressor'}) {\n   \t\t$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});\n   \t}\n\n-- \nJakub Narębski\n"},{"id":"178864","messageId":"4EB488C9.2050301@aei.ca","threadId":"28837","inReplyTo":"m3fwi350ou.fsf@localhost.localdomain","subject":"Re: [PATCHv2] Add options to specify snapshot file name, prefix","fromName":"Thomas Guyot-Sionnest","fromEmail":"dermoth@aei.ca","sentAt":"2011-11-05T00:52:25Z","receivedAt":"2011-11-05T00:52:25Z","isPatch":false,"sender":{"key":"dermoth@aei.ca","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nOn 11-11-04 12:10 PM, Jakub Narebski wrote:\n> Thomas Guyot-Sionnest <dermoth@aei.ca> writes:\n> \n>> commit b629275 implemented \"smart\" snapshot names and prefixes. I have\n>> scripts that used to rely on the old behaviour which allowed in some\n>> cases to have fixed prefix, and would require modifications to work with\n>> newer Gitweb.\n> \n> If scripts use 'wget' or 'curl' you can always change the name of\n> saved file:\n> \n>   wget -O <file> ...\n>   curl -o <file> ...\n> \n> If downloaded snapshot is compressed tarfile, you can use\n> --strip-components=1 to strip prefix.\n\nI actually didn't care about the filename (in my script I pipe straight\nto tar, and in a python app I have that will use snapshots I have I\nplanned on \"opening\" the url as a stream directly with the tarfile lib);\nit was just as easy to add both anyway.\n\nI thought I had looked up the tar man page for an option that strips the\npath, clearly I missed that one. :)\n\n>> This patch adds two parameters for overriding the snapshot name and\n>> prefix, sn and sp respectively. For example, to get a snapshot\n>> named \"myproject.[suffix]\" with no prefix one can add this query string:\n>>   ?sn=myproject;sp=\n> \n> Would you need support for expandable parameters in both (a la\n> 'action' feature)?\n\nI'm not sure what you mean... I never tinkered with gitweb.pl directly\nbefore.\n\n> [...] \n>> @@ -6684,11 +6686,19 @@ sub git_snapshot {\n>>  \t}\n>>  \n>>  \tmy ($name, $prefix) = snapshot_name($project, $hash);\n>> +\tif (defined($input_params{'snapshot_name'})) {\n>> +\t\t$name = $input_params{'snapshot_name'};\n>> +\t}\n>> +\tif (defined($input_params{'snapshot_prefix'})) {\n>> +\t\t$prefix = $input_params{'snapshot_prefix'};\n>> +\t} else {\n>> +\t\t$prefix .= '/';\n>> +\t}\n>>  \tmy $filename = \"$name$known_snapshot_formats{$format}{'suffix'}\";\n>>  \tmy $cmd = quote_command(\n>>  \t\tgit_cmd(), 'archive',\n>>  \t\t\"--format=$known_snapshot_formats{$format}{'format'}\",\n>> -\t\t\"--prefix=$prefix/\", $hash);\n>> +\t\t\"--prefix=$prefix\", $hash);\n>>  \tif (exists $known_snapshot_formats{$format}{'compressor'}) {\n>>  \t\t$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});\n>>  \t}\n> \n> I wonder if you really want to allow prefix which do not end in '/'\n\nI kind of agree, yet considering its lack of \"front-end\" visibility it\nmade me think of plumbing commands like git-checkout-index (which I use\nsometimes to replace the \"missing\" git export) where prefix is nothing\nmore than an appended string to file names.\n\nAnd now I remember, this is also exactly how git-archive works.\n\n> (which would be suprising, isn't it), or just allow empty prefix too.\n>\n>\n> For example\n> \n>   @@ -6684,11 +6686,19 @@ sub git_snapshot {\n>    \t}\n>    \n>    \tmy ($name, $prefix) = snapshot_name($project, $hash);\n>   +\tif (defined($input_params{'snapshot_name'})) {\n>   +\t\t$name = $input_params{'snapshot_name'};\n>   +\t}\n>   +\tif (defined($input_params{'snapshot_prefix'})) {\n>   +\t\t$prefix = $input_params{'snapshot_prefix'};\n>   +\t}\n>    \tmy $filename = \"$name$known_snapshot_formats{$format}{'suffix'}\";\n>    \tmy $cmd = quote_command(\n>    \t\tgit_cmd(), 'archive',\n>    \t\t\"--format=$known_snapshot_formats{$format}{'format'}\",\n>   -\t\t\"--prefix=$prefix/\", $hash);\n>   +\t\t($prefix eq \"\" ? () : \"--prefix=$prefix\"), $hash);\n>    \tif (exists $known_snapshot_formats{$format}{'compressor'}) {\n>    \t\t$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});\n>    \t}\n> \n\nYou still have to add the /, i.e.:\n\n>   +\t\t($prefix eq \"\" ? () : \"--prefix=$prefix/\"), $hash);\n\nAnd personally, I think git-archive is the one that should add a / - it\nhas much more visibility to end-users than this obscure query-string.\n\n- -- \nThomas\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\nComment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/\n\niEYEARECAAYFAk60iMAACgkQ6dZ+Kt5BchbOFwCgmDuUVd9vI+ZC8JDQPS+SC7e2\nFpIAnAkf6BrmAcvY/3GA1wjQvR9s50c6\n=0pb2\n-----END PGP SIGNATURE-----\n"},{"id":"178889","messageId":"201111050947.15440.jnareb@gmail.com","threadId":"28837","inReplyTo":"4EB488C9.2050301@aei.ca","subject":"Re: [PATCHv2] Add options to specify snapshot file name, prefix","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-11-05T08:47:14Z","receivedAt":"2011-11-05T08:47:14Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sat, 5 Nov 2011, Thomas Guyot-Sionnest wrote:\n> On 11-11-04 12:10 PM, Jakub Narebski wrote:\n> > Thomas Guyot-Sionnest <dermoth@aei.ca> writes:\n> >\n> > > commit b629275 implemented \"smart\" snapshot names and prefixes. I have\n> > > scripts that used to rely on the old behaviour which allowed in some\n> > > cases to have fixed prefix, and would require modifications to work with\n> > > newer Gitweb.\n[...]\n> > > This patch adds two parameters for overriding the snapshot name and\n> > > prefix, sn and sp respectively. For example, to get a snapshot\n> > > named \"myproject.[suffix]\" with no prefix one can add this query string:\n> > >   ?sn=myproject;sp=\n> >\n> > Would you need support for expandable parameters in both (a la\n> > 'action' feature)?\n> \n> I'm not sure what you mean... I never tinkered with gitweb.pl directly\n> before.\n\nI'm sorry I didn't make it clear what I meant here.\n\nWhat I wanted to ask is if you would need support for snapshot names\nlike for example\n\n   myproject-<full sha1>.tar.gz\n \nIt means that snapshot name depends on commit / tag / tree being archived;\nfor that you would need e.g.\n\n   ...?sn=myproject-%H.tar.gz;sp=\n\nBut even if there would be need for this, it should be anyway put into\nseparate commit.\n\n\nIn short: forget about this comment.\n\n[...]\n> > > @@ -6684,11 +6686,19 @@ sub git_snapshot {\n> > >  \t}\n> > >\n> > >  \tmy ($name, $prefix) = snapshot_name($project, $hash);\n> > > +\tif (defined($input_params{'snapshot_name'})) {\n> > > +\t\t$name = $input_params{'snapshot_name'};\n> > > +\t}\n> > > +\tif (defined($input_params{'snapshot_prefix'})) {\n> > > +\t\t$prefix = $input_params{'snapshot_prefix'};\n> > > +\t} else {\n> > > +\t\t$prefix .= '/';\n> > > +\t}\n> > >  \tmy $filename = \"$name$known_snapshot_formats{$format}{'suffix'}\";\n> > >  \tmy $cmd = quote_command(\n> > >  \t\tgit_cmd(), 'archive',\n> > >  \t\t\"--format=$known_snapshot_formats{$format}{'format'}\",\n> > > -\t\t\"--prefix=$prefix/\", $hash);\n> > > +\t\t\"--prefix=$prefix\", $hash);\n> > >  \tif (exists $known_snapshot_formats{$format}{'compressor'}) {\n> > >  \t\t$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});\n> > >  \t}\n> >\n> > I wonder if you really want to allow prefix which do not end in '/'\n> \n> I kind of agree, yet considering its lack of \"front-end\" visibility it\n> made me think of plumbing commands like git-checkout-index (which I use\n> sometimes to replace the \"missing\" git export) where prefix is nothing\n> more than an appended string to file names.\n> \n> And now I remember, this is also exactly how git-archive works.\n\nRight.\n\nI wonder if anybody is using \"git archive\" with prefix that DOESN'T\nend with a '/'...\n \n> > (which would be suprising, isn't it), or just allow empty prefix too.\n> >\n> >\n> > For example\n> >\n> >   @@ -6684,11 +6686,19 @@ sub git_snapshot {\n> >    \t}\n> >\n> >    \tmy ($name, $prefix) = snapshot_name($project, $hash);\n> >   +\tif (defined($input_params{'snapshot_name'})) {\n> >   +\t\t$name = $input_params{'snapshot_name'};\n> >   +\t}\n> >   +\tif (defined($input_params{'snapshot_prefix'})) {\n> >   +\t\t$prefix = $input_params{'snapshot_prefix'};\n> >   +\t}\n> >    \tmy $filename = \"$name$known_snapshot_formats{$format}{'suffix'}\";\n> >    \tmy $cmd = quote_command(\n> >    \t\tgit_cmd(), 'archive',\n> >    \t\t\"--format=$known_snapshot_formats{$format}{'format'}\",\n> >   -\t\t\"--prefix=$prefix/\", $hash);\n> >   +\t\t($prefix eq \"\" ? () : \"--prefix=$prefix\"), $hash);\n> >    \tif (exists $known_snapshot_formats{$format}{'compressor'}) {\n> >    \t\t$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});\n> >    \t}\n> >\n> \n> You still have to add the /, i.e.:\n> \n> >   +\t\t($prefix eq \"\" ? () : \"--prefix=$prefix/\"), $hash);\n\nTrue.  Sorry about that.\n \n> And personally, I think git-archive is the one that should add a / - it\n> has much more visibility to end-users than this obscure query-string.\n\nSo should we expect a re-roll?\n\n\nP.S. I'd like to point out that git is now in pre-release feature freeze,\nso please don't expect for these changes to appear in 'master' soon, though\nmost probably they would be available in 'pu' for the time being.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"178892","messageId":"201111051018.22995.jnareb@gmail.com","threadId":"28837","inReplyTo":"201111050947.15440.jnareb@gmail.com","subject":"Re: [PATCHv2] Add options to specify snapshot file name, prefix","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-11-05T09:18:22Z","receivedAt":"2011-11-05T09:18:22Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jakub Narebski wrote:\n\n> So should we expect a re-roll?\n\nBy the way, those new query parameters ('sn' and 'sp') should IMHO\nbe documented in Documentation/gitweb.txt i.e. gitweb(1) manpage.\n\nAlso, shouldn't you infer snapshot format from snapshot name \n(\"git archive\" does part of that... but not the compression part)?\n\n-- \nJakub Narebski\nPoland\n"}]}