* [PATCHv2] Add options to specify snapshot file name, prefix [not found] <1320302318-28315-1-git-send-email-dermoth@aei.ca> @ 2011-11-04 0:53 ` Thomas Guyot-Sionnest 2011-11-04 16:10 ` Jakub Narebski 0 siblings, 1 reply; 5+ messages in thread From: Thomas Guyot-Sionnest @ 2011-11-04 0:53 UTC (permalink / raw) To: git; +Cc: Thomas Guyot-Sionnest commit b629275 implemented "smart" snapshot names and prefixes. I have scripts that used to rely on the old behaviour which allowed in some cases to have fixed prefix, and would require modifications to work with newer Gitweb. This patch adds two parameters for overriding the snapshot name and prefix, sn and sp respectively. For example, to get a snapshot named "myproject.[suffix]" with no prefix one can add this query string: ?sn=myproject;sp= Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca> --- gitweb/gitweb.perl | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 4f0c3bd..9c91f01 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -756,6 +756,8 @@ our @cgi_param_mapping = ( searchtext => "s", searchtype => "st", snapshot_format => "sf", + snapshot_name => "sn", + snapshot_prefix => "sp", extra_options => "opt", search_use_regexp => "sr", ctag => "by_tag", @@ -6684,11 +6686,19 @@ sub git_snapshot { } my ($name, $prefix) = snapshot_name($project, $hash); + if (defined($input_params{'snapshot_name'})) { + $name = $input_params{'snapshot_name'}; + } + if (defined($input_params{'snapshot_prefix'})) { + $prefix = $input_params{'snapshot_prefix'}; + } else { + $prefix .= '/'; + } my $filename = "$name$known_snapshot_formats{$format}{'suffix'}"; my $cmd = quote_command( git_cmd(), 'archive', "--format=$known_snapshot_formats{$format}{'format'}", - "--prefix=$prefix/", $hash); + "--prefix=$prefix", $hash); if (exists $known_snapshot_formats{$format}{'compressor'}) { $cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}}); } -- 1.7.7.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCHv2] Add options to specify snapshot file name, prefix 2011-11-04 0:53 ` [PATCHv2] Add options to specify snapshot file name, prefix Thomas Guyot-Sionnest @ 2011-11-04 16:10 ` Jakub Narebski 2011-11-05 0:52 ` Thomas Guyot-Sionnest 0 siblings, 1 reply; 5+ messages in thread From: Jakub Narebski @ 2011-11-04 16:10 UTC (permalink / raw) To: Thomas Guyot-Sionnest; +Cc: git, Jakub Narebski Thomas Guyot-Sionnest <dermoth@aei.ca> writes: > commit b629275 implemented "smart" snapshot names and prefixes. I have > scripts that used to rely on the old behaviour which allowed in some > cases to have fixed prefix, and would require modifications to work with > newer Gitweb. If scripts use 'wget' or 'curl' you can always change the name of saved file: wget -O <file> ... curl -o <file> ... If downloaded snapshot is compressed tarfile, you can use --strip-components=1 to strip prefix. > This patch adds two parameters for overriding the snapshot name and > prefix, sn and sp respectively. For example, to get a snapshot > named "myproject.[suffix]" with no prefix one can add this query string: > ?sn=myproject;sp= Would you need support for expandable parameters in both (a la 'action' feature)? [...] > @@ -6684,11 +6686,19 @@ sub git_snapshot { > } > > my ($name, $prefix) = snapshot_name($project, $hash); > + if (defined($input_params{'snapshot_name'})) { > + $name = $input_params{'snapshot_name'}; > + } > + if (defined($input_params{'snapshot_prefix'})) { > + $prefix = $input_params{'snapshot_prefix'}; > + } else { > + $prefix .= '/'; > + } > my $filename = "$name$known_snapshot_formats{$format}{'suffix'}"; > my $cmd = quote_command( > git_cmd(), 'archive', > "--format=$known_snapshot_formats{$format}{'format'}", > - "--prefix=$prefix/", $hash); > + "--prefix=$prefix", $hash); > if (exists $known_snapshot_formats{$format}{'compressor'}) { > $cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}}); > } I wonder if you really want to allow prefix which do not end in '/' (which would be suprising, isn't it), or just allow empty prefix too. For example @@ -6684,11 +6686,19 @@ sub git_snapshot { } my ($name, $prefix) = snapshot_name($project, $hash); + if (defined($input_params{'snapshot_name'})) { + $name = $input_params{'snapshot_name'}; + } + if (defined($input_params{'snapshot_prefix'})) { + $prefix = $input_params{'snapshot_prefix'}; + } my $filename = "$name$known_snapshot_formats{$format}{'suffix'}"; my $cmd = quote_command( git_cmd(), 'archive', "--format=$known_snapshot_formats{$format}{'format'}", - "--prefix=$prefix/", $hash); + ($prefix eq "" ? () : "--prefix=$prefix"), $hash); if (exists $known_snapshot_formats{$format}{'compressor'}) { $cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}}); } -- Jakub Narębski ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCHv2] Add options to specify snapshot file name, prefix 2011-11-04 16:10 ` Jakub Narebski @ 2011-11-05 0:52 ` Thomas Guyot-Sionnest 2011-11-05 8:47 ` Jakub Narebski 0 siblings, 1 reply; 5+ messages in thread From: Thomas Guyot-Sionnest @ 2011-11-05 0:52 UTC (permalink / raw) To: Jakub Narebski; +Cc: git -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11-11-04 12:10 PM, Jakub Narebski wrote: > Thomas Guyot-Sionnest <dermoth@aei.ca> writes: > >> commit b629275 implemented "smart" snapshot names and prefixes. I have >> scripts that used to rely on the old behaviour which allowed in some >> cases to have fixed prefix, and would require modifications to work with >> newer Gitweb. > > If scripts use 'wget' or 'curl' you can always change the name of > saved file: > > wget -O <file> ... > curl -o <file> ... > > If downloaded snapshot is compressed tarfile, you can use > --strip-components=1 to strip prefix. I actually didn't care about the filename (in my script I pipe straight to tar, and in a python app I have that will use snapshots I have I planned on "opening" the url as a stream directly with the tarfile lib); it was just as easy to add both anyway. I thought I had looked up the tar man page for an option that strips the path, clearly I missed that one. :) >> This patch adds two parameters for overriding the snapshot name and >> prefix, sn and sp respectively. For example, to get a snapshot >> named "myproject.[suffix]" with no prefix one can add this query string: >> ?sn=myproject;sp= > > Would you need support for expandable parameters in both (a la > 'action' feature)? I'm not sure what you mean... I never tinkered with gitweb.pl directly before. > [...] >> @@ -6684,11 +6686,19 @@ sub git_snapshot { >> } >> >> my ($name, $prefix) = snapshot_name($project, $hash); >> + if (defined($input_params{'snapshot_name'})) { >> + $name = $input_params{'snapshot_name'}; >> + } >> + if (defined($input_params{'snapshot_prefix'})) { >> + $prefix = $input_params{'snapshot_prefix'}; >> + } else { >> + $prefix .= '/'; >> + } >> my $filename = "$name$known_snapshot_formats{$format}{'suffix'}"; >> my $cmd = quote_command( >> git_cmd(), 'archive', >> "--format=$known_snapshot_formats{$format}{'format'}", >> - "--prefix=$prefix/", $hash); >> + "--prefix=$prefix", $hash); >> if (exists $known_snapshot_formats{$format}{'compressor'}) { >> $cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}}); >> } > > I wonder if you really want to allow prefix which do not end in '/' I kind of agree, yet considering its lack of "front-end" visibility it made me think of plumbing commands like git-checkout-index (which I use sometimes to replace the "missing" git export) where prefix is nothing more than an appended string to file names. And now I remember, this is also exactly how git-archive works. > (which would be suprising, isn't it), or just allow empty prefix too. > > > For example > > @@ -6684,11 +6686,19 @@ sub git_snapshot { > } > > my ($name, $prefix) = snapshot_name($project, $hash); > + if (defined($input_params{'snapshot_name'})) { > + $name = $input_params{'snapshot_name'}; > + } > + if (defined($input_params{'snapshot_prefix'})) { > + $prefix = $input_params{'snapshot_prefix'}; > + } > my $filename = "$name$known_snapshot_formats{$format}{'suffix'}"; > my $cmd = quote_command( > git_cmd(), 'archive', > "--format=$known_snapshot_formats{$format}{'format'}", > - "--prefix=$prefix/", $hash); > + ($prefix eq "" ? () : "--prefix=$prefix"), $hash); > if (exists $known_snapshot_formats{$format}{'compressor'}) { > $cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}}); > } > You still have to add the /, i.e.: > + ($prefix eq "" ? () : "--prefix=$prefix/"), $hash); And personally, I think git-archive is the one that should add a / - it has much more visibility to end-users than this obscure query-string. - -- Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk60iMAACgkQ6dZ+Kt5BchbOFwCgmDuUVd9vI+ZC8JDQPS+SC7e2 FpIAnAkf6BrmAcvY/3GA1wjQvR9s50c6 =0pb2 -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCHv2] Add options to specify snapshot file name, prefix 2011-11-05 0:52 ` Thomas Guyot-Sionnest @ 2011-11-05 8:47 ` Jakub Narebski 2011-11-05 9:18 ` Jakub Narebski 0 siblings, 1 reply; 5+ messages in thread From: Jakub Narebski @ 2011-11-05 8:47 UTC (permalink / raw) To: Thomas Guyot-Sionnest; +Cc: git On Sat, 5 Nov 2011, Thomas Guyot-Sionnest wrote: > On 11-11-04 12:10 PM, Jakub Narebski wrote: > > Thomas Guyot-Sionnest <dermoth@aei.ca> writes: > > > > > commit b629275 implemented "smart" snapshot names and prefixes. I have > > > scripts that used to rely on the old behaviour which allowed in some > > > cases to have fixed prefix, and would require modifications to work with > > > newer Gitweb. [...] > > > This patch adds two parameters for overriding the snapshot name and > > > prefix, sn and sp respectively. For example, to get a snapshot > > > named "myproject.[suffix]" with no prefix one can add this query string: > > > ?sn=myproject;sp= > > > > Would you need support for expandable parameters in both (a la > > 'action' feature)? > > I'm not sure what you mean... I never tinkered with gitweb.pl directly > before. I'm sorry I didn't make it clear what I meant here. What I wanted to ask is if you would need support for snapshot names like for example myproject-<full sha1>.tar.gz It means that snapshot name depends on commit / tag / tree being archived; for that you would need e.g. ...?sn=myproject-%H.tar.gz;sp= But even if there would be need for this, it should be anyway put into separate commit. In short: forget about this comment. [...] > > > @@ -6684,11 +6686,19 @@ sub git_snapshot { > > > } > > > > > > my ($name, $prefix) = snapshot_name($project, $hash); > > > + if (defined($input_params{'snapshot_name'})) { > > > + $name = $input_params{'snapshot_name'}; > > > + } > > > + if (defined($input_params{'snapshot_prefix'})) { > > > + $prefix = $input_params{'snapshot_prefix'}; > > > + } else { > > > + $prefix .= '/'; > > > + } > > > my $filename = "$name$known_snapshot_formats{$format}{'suffix'}"; > > > my $cmd = quote_command( > > > git_cmd(), 'archive', > > > "--format=$known_snapshot_formats{$format}{'format'}", > > > - "--prefix=$prefix/", $hash); > > > + "--prefix=$prefix", $hash); > > > if (exists $known_snapshot_formats{$format}{'compressor'}) { > > > $cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}}); > > > } > > > > I wonder if you really want to allow prefix which do not end in '/' > > I kind of agree, yet considering its lack of "front-end" visibility it > made me think of plumbing commands like git-checkout-index (which I use > sometimes to replace the "missing" git export) where prefix is nothing > more than an appended string to file names. > > And now I remember, this is also exactly how git-archive works. Right. I wonder if anybody is using "git archive" with prefix that DOESN'T end with a '/'... > > (which would be suprising, isn't it), or just allow empty prefix too. > > > > > > For example > > > > @@ -6684,11 +6686,19 @@ sub git_snapshot { > > } > > > > my ($name, $prefix) = snapshot_name($project, $hash); > > + if (defined($input_params{'snapshot_name'})) { > > + $name = $input_params{'snapshot_name'}; > > + } > > + if (defined($input_params{'snapshot_prefix'})) { > > + $prefix = $input_params{'snapshot_prefix'}; > > + } > > my $filename = "$name$known_snapshot_formats{$format}{'suffix'}"; > > my $cmd = quote_command( > > git_cmd(), 'archive', > > "--format=$known_snapshot_formats{$format}{'format'}", > > - "--prefix=$prefix/", $hash); > > + ($prefix eq "" ? () : "--prefix=$prefix"), $hash); > > if (exists $known_snapshot_formats{$format}{'compressor'}) { > > $cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}}); > > } > > > > You still have to add the /, i.e.: > > > + ($prefix eq "" ? () : "--prefix=$prefix/"), $hash); True. Sorry about that. > And personally, I think git-archive is the one that should add a / - it > has much more visibility to end-users than this obscure query-string. So should we expect a re-roll? P.S. I'd like to point out that git is now in pre-release feature freeze, so please don't expect for these changes to appear in 'master' soon, though most probably they would be available in 'pu' for the time being. -- Jakub Narebski Poland ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCHv2] Add options to specify snapshot file name, prefix 2011-11-05 8:47 ` Jakub Narebski @ 2011-11-05 9:18 ` Jakub Narebski 0 siblings, 0 replies; 5+ messages in thread From: Jakub Narebski @ 2011-11-05 9:18 UTC (permalink / raw) To: Thomas Guyot-Sionnest; +Cc: git Jakub Narebski wrote: > So should we expect a re-roll? By the way, those new query parameters ('sn' and 'sp') should IMHO be documented in Documentation/gitweb.txt i.e. gitweb(1) manpage. Also, shouldn't you infer snapshot format from snapshot name ("git archive" does part of that... but not the compression part)? -- Jakub Narebski Poland ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-05 9:18 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1320302318-28315-1-git-send-email-dermoth@aei.ca> 2011-11-04 0:53 ` [PATCHv2] Add options to specify snapshot file name, prefix Thomas Guyot-Sionnest 2011-11-04 16:10 ` Jakub Narebski 2011-11-05 0:52 ` Thomas Guyot-Sionnest 2011-11-05 8:47 ` Jakub Narebski 2011-11-05 9:18 ` Jakub Narebski
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).