git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] gitweb.perl : added ability to "git archive" just certain paths (files or subdirs, not whole repo) via gitweb interface
@ 2016-03-11 13:24 Jim Klimov
  2016-03-11 13:24 ` [PATCH 2/6] gitweb.perl : added ability to debug requests coming through gitweb interface by adding an option to request URL (also requires server-side envvar "GITWEB_MAY_DEBUG=yes") Jim Klimov
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jim Klimov @ 2016-03-11 13:24 UTC (permalink / raw)
  To: git; +Cc: Jim Klimov

---
 gitweb/gitweb.perl | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 05d7910..030d429 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -7328,6 +7328,15 @@ sub git_snapshot {
 		die_error(403, "Unsupported snapshot format");
 	}
 
+	if (!defined($hash)) {
+		$hash="";
+		if ( $file_name && $file_name =~ /^([^:]*):(.*)$/ ) {
+			$hash = "$1";
+			$file_name = "$2";
+		}
+		if ( $hash eq "") { $hash = "HEAD"; }
+		printf STDERR "Defaulted hash to '$hash' ('h=' URL argument was missing)\n";
+	}
 	my $type = git_get_type("$hash^{}");
 	if (!$type) {
 		die_error(404, 'Object does not exist');
@@ -7345,6 +7354,14 @@ sub git_snapshot {
 		git_cmd(), 'archive',
 		"--format=$known_snapshot_formats{$format}{'format'}",
 		"--prefix=$prefix/", $hash);
+	if ($file_name) {
+		# To fetch several pathnames use space-separation, e.g.
+		# "...git-web?p=proj.git;a=snapshot;f=file1%20file2
+		# To fetch pathnames with spaces, escape them, e.g.
+		# "...git-web?p=proj.git;a=snapshot;f=file\%20name
+		$cmd .= " " . $file_name;
+	}
+
 	if (exists $known_snapshot_formats{$format}{'compressor'}) {
 		$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});
 	}
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-03-11 13:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-11 13:24 [PATCH 1/6] gitweb.perl : added ability to "git archive" just certain paths (files or subdirs, not whole repo) via gitweb interface Jim Klimov
2016-03-11 13:24 ` [PATCH 2/6] gitweb.perl : added ability to debug requests coming through gitweb interface by adding an option to request URL (also requires server-side envvar "GITWEB_MAY_DEBUG=yes") Jim Klimov
2016-03-11 13:24 ` [PATCH 3/6] gitweb.perl : added ability to DEBUG progression through "git archive" Jim Klimov
2016-03-11 13:24 ` [PATCH 4/6] gitweb.perl support for snapshots with lists of specified files is now tested Jim Klimov
2016-03-11 13:24 ` [PATCH 5/6] gitweb.perl changed (and tested) to return HTTP-404 when missing objects are requested via snapshot Jim Klimov
2016-03-11 13:24 ` [PATCH 6/6] gitweb.perl : the optional DEBUG functionality is now unit-tested Jim Klimov

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).