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

[PATCH] gitweb: change filename/directory name of snapshots

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Jun 7, 2007, 09:27 UTC
Message-ID
<20070607092708.GA25097@moooo.ath.cx>

/.git or .git is removed from the project name and the basename of the remaining path is used as the beginning of the filename and as the directory in the archive.

The regexp will actually not strip off /.git or .git if there wouldn't be anything left after removing it.

Currently the full project name is used as directory in the archive and the basename is used as filename. For example a repository named foo/bar/.git will have a archive named .git-<version>.* and extract to foo/bar/.git. With this patch the file is named bar-<version>.* and extracts to bar.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
Imho the old behaviour does not make much sense but perhaps there are
users out there relying on the old behaviour.  OTOH relying on
a web interface not to change is quite bad, especially if you
could do the same using the git repository which would be much
more reliable.
---
 gitweb/gitweb.perl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e92596c..1777393 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4001,8 +4001,10 @@ sub git_snapshot {
 
 	my $git = git_cmd_str();
 	my $name = $project;
+	$name =~ s,([^/])/*\.git$,$1,;
+	$name = basename($name);
+	my $filename = to_utf8($name);
 	$name =~ s/\047/\047\\\047\047/g;
-	my $filename = to_utf8(basename($project));
 	my $cmd;
 	if ($suffix eq 'zip') {
 		$filename .= "-$hash.$suffix";
-- 
1.5.2.1.888.gd5e4e
Next: Junio C Hamano
Message 1 of 4 in “gitweb: change filename/directory name of snapshots”
  1. gitweb: change filename/directory name of snapshotsMatthias Lederhofer, Jun 7, 2007
  2. Junio C HamanoJun 8, 2007
  3. Jakub NarebskiJun 8, 2007
  4. Petr BaudisJun 8, 2007

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.