git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv2] Add options to specify snapshot file name, prefix

From
Jakub Narebski <jnareb@gmail.com>
Date
Nov 4, 2011, 16:10 UTC
Message-ID
<m3fwi350ou.fsf@localhost.localdomain>
In-Reply-To
<1320367999-24435-1-git-send-email-dermoth@aei.ca>
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)?

[...] 
Show 21 quoted lines
> @@ -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
Previous: Thomas Guyot-SionnestNext: Thomas Guyot-Sionnest
Message 2 of 5 in “[PATCHv2] Add options to specify snapshot file name, prefix”
  1. Thomas Guyot-SionnestNov 4, 2011
  2. Jakub NarebskiNov 4, 2011
  3. Thomas Guyot-SionnestNov 5, 2011
  4. Jakub NarebskiNov 5, 2011
  5. Jakub NarebskiNov 5, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.