git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Guyot-Sionnest <dermoth@aei.ca>
To: git@vger.kernel.org
Cc: Thomas Guyot-Sionnest <dermoth@aei.ca>
Subject: [PATCHv2] Add options to specify snapshot file name, prefix
Date: Thu,  3 Nov 2011 20:53:19 -0400	[thread overview]
Message-ID: <1320367999-24435-1-git-send-email-dermoth@aei.ca> (raw)
In-Reply-To: <1320302318-28315-1-git-send-email-dermoth@aei.ca>

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

       reply	other threads:[~2011-11-04  0:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1320302318-28315-1-git-send-email-dermoth@aei.ca>
2011-11-04  0:53 ` Thomas Guyot-Sionnest [this message]
2011-11-04 16:10   ` [PATCHv2] Add options to specify snapshot file name, prefix Jakub Narebski
2011-11-05  0:52     ` Thomas Guyot-Sionnest
2011-11-05  8:47       ` Jakub Narebski
2011-11-05  9:18         ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1320367999-24435-1-git-send-email-dermoth@aei.ca \
    --to=dermoth@aei.ca \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).