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

4 messages from 2007-06-07 to 2007-06-08. Participants: Matthias Lederhofer, Junio C Hamano, Jakub Narebski, Petr Baudis.
Thread: https://gitlist.dev/t/8481

## Matthias Lederhofer, 2007-06-07 09:27

Subject: [PATCH] gitweb: change filename/directory name of snapshots
Message-ID: <20070607092708.GA25097@moooo.ath.cx>
URL: https://gitlist.dev/e/20070607092708.GA25097%40moooo.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

```

## Junio C Hamano, 2007-06-08 08:43

Subject: Re: [PATCH] gitweb: change filename/directory name of snapshots
Message-ID: <7v4pliltuv.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v4pliltuv.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20070607092708.GA25097@moooo.ath.cx>

```
Matthias Lederhofer <matled@gmx.net> writes:

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

Makes sense to me for "foo/bar/.git", but I am not sure if we
would want to do this to "foo/bar.git".  Opinions?

```

## Jakub Narebski, 2007-06-08 11:46

Subject: Re: [PATCH] gitweb: change filename/directory name of snapshots
Message-ID: <f4bf7g$kpe$1@sea.gmane.org>
URL: https://gitlist.dev/e/f4bf7g%24kpe%241%40sea.gmane.org
In-Reply-To: <7v4pliltuv.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:

> Matthias Lederhofer <matled@gmx.net> writes:
> 
>> /.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.
> 
> Makes sense to me for "foo/bar/.git", but I am not sure if we
> would want to do this to "foo/bar.git".  Opinions?

I'd like to have snapshot called bar-<sha1>.tar.gz in first case,
and bar.git-<sha1>.tar.gz (without stripping .git) in the second,
but I wouldn't protest too much about having bar-<sha1>.tar.gz
also in second case.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Petr Baudis, 2007-06-08 17:18

Subject: Re: [PATCH] gitweb: change filename/directory name of snapshots
Message-ID: <20070608171811.GX4489@pasky.or.cz>
URL: https://gitlist.dev/e/20070608171811.GX4489%40pasky.or.cz
In-Reply-To: <7v4pliltuv.fsf@assigned-by-dhcp.cox.net>

```
On Fri, Jun 08, 2007 at 10:43:04AM CEST, Junio C Hamano wrote:
> Matthias Lederhofer <matled@gmx.net> writes:
> 
> > /.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.
> 
> Makes sense to me for "foo/bar/.git", but I am not sure if we
> would want to do this to "foo/bar.git".  Opinions?

I wouldn't personally really mind getting rid of the .git suffix in both
cases.  Yes, we are used to seeing the ".git" in the name, but I can't
think of any other reasons not to chop it off.

Having the .git in the archive name might be even more confusing since
there is a pseudo-convention (that I'm not sure anyone except me
follows, so maybe not :) that repositories have .git in the name while
working trees don't, and that tarball contains a working tree.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Ever try. Ever fail. No matter. // Try again. Fail again. Fail better.
		-- Samuel Beckett

```
