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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]