Skip to contentSkip to conversation

Make the output of "git svn clone" less confusing.

PATCH NAK David Kågedal 3 participants 6 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make the output of "git svn clone" less confusing.

The problem is that the first thing it prints is

Initialized empty Git repository in .git/

even if actually created a subdirectory and changed into it first. But to the user, it looks like it is creating a .git/ dir in the directory he/she is started git from.

---
 git-svn.perl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

This change makes it more chatty, which might not be a good thing. But I think the previous output was worse.

git-svn.perl +1 -0
index 777e436..d4450ca 100755
@@ -286,6 +286,7 @@ sub do_git_init_db {
 
 sub init_subdir {
 	my $repo_path = shift or return;
+	print "Creating directory $repo_path\n";
 	mkpath([$repo_path]) unless -d $repo_path;
 	chdir $repo_path or die "Couldn't chdir to $repo_path: $!\n";
 	$ENV{GIT_DIR} = '.git';
Signature · 4 lines
1.5.3.4.213.gb3127-dirty

-- 
David Kågedal
#1 lore raw
Quoted 7 lines · David Kågedal

The problem is that the first thing it prints is

Initialized empty Git repository in .git/

even if actually created a subdirectory and changed into it first. But to the user, it looks like it is creating a .git/ dir in the directory he/she is started git from.

Thanks for bringing it up I just noticed this the other day myself and thought it might be confusing.

Quoted 12 lines
---
 git-svn.perl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

This change makes it more chatty, which might not be a good thing. But I think the previous output was worse.

git-svn.perl +0 -0
index 777e436..d4450ca 100755

git-svn.perl sub do_git_init_db { · line 291

Quoted 6 lines
git-svn.perl +1 -0
@@ -286,6 +286,7 @@ sub do_git_init_db {
 
 sub init_subdir {
 	my $repo_path = shift or return;
+	print "Creating directory $repo_path\n";
 	mkpath([$repo_path]) unless -d $repo_path;
 	chdir $repo_path or die "Couldn't chdir to $repo_path: $!\n";

Since mkpath() isn't guaranteed to get called, maybe putting a

print "Entering directory $repo_path\n"

right before the chdir is better.

The other option would be to alter git-init to print the absolute path of the repository being initialized...

Signature · 1 line
Eric Wong
#2 lore raw
Quoted 14 lines · Eric Wong

git-svn.perl sub do_git_init_db { · line 291

Quoted 11 lines
git-svn.perl +1 -0
index 777e436..d4450ca 100755
@@ -286,6 +286,7 @@ sub do_git_init_db {
 
 sub init_subdir {
 	my $repo_path = shift or return;
+	print "Creating directory $repo_path\n";
 	mkpath([$repo_path]) unless -d $repo_path;
 	chdir $repo_path or die "Couldn't chdir to $repo_path: $!\n";

Since mkpath() isn't guaranteed to get called, maybe putting a

Quoted 3 lines

print "Entering directory $repo_path\n"

right before the chdir is better.

You're probably right.

Quoted 2 lines

The other option would be to alter git-init to print the absolute path of the repository being initialized...

Absolute paths don't sound like a great idea to me. Ideally, I'd like to see the path I gave it, or something relative to the working directory. That is, *my* working directory, and not some internal one because one of the tools did a chdir.

Can't we make init_subdir in git-svn not chdir, instead? Like this, highly untested?

git-svn.perl +1 -2
@@ -288,8 +288,7 @@ sub init_subdir {
 	my $repo_path = shift or return;
 	print "Creating directory $repo_path\n";
 	mkpath([$repo_path]) unless -d $repo_path;
-	chdir $repo_path or die "Couldn't chdir to $repo_path: $!\n";
-	$ENV{GIT_DIR} = '.git';
+	$ENV{GIT_DIR} = '$repo_path/.git';
 }
 
 sub cmd_clone {
Signature · 1 line
David Kågedal
#3 lore raw
In reply to David Kågedal
Quoted 7 lines · David Kgedal

The problem is that the first thing it prints is

Initialized empty Git repository in .git/

even if actually created a subdirectory and changed into it first. But to the user, it looks like it is creating a .git/ dir in the directory he/she is started git from.

Eric, ack/nack?

Quoted 21 lines
---
 git-svn.perl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

This change makes it more chatty, which might not be a good thing. But I think the previous output was worse.

git-svn.perl +1 -0
index 777e436..d4450ca 100755
@@ -286,6 +286,7 @@ sub do_git_init_db {
 
 sub init_subdir {
 	my $repo_path = shift or return;
+	print "Creating directory $repo_path\n";
 	mkpath([$repo_path]) unless -d $repo_path;
 	chdir $repo_path or die "Couldn't chdir to $repo_path: $!\n";
 	$ENV{GIT_DIR} = '.git';
Signature · 1 line
1.5.3.4.213.gb3127-dirty
Signature · 1 line
Shawn.
#4 lore raw
Quoted 10 lines · Shawn O. Pearce
Quoted 7 lines · David Kågedal

The problem is that the first thing it prints is

Initialized empty Git repository in .git/

even if actually created a subdirectory and changed into it first. But to the user, it looks like it is creating a .git/ dir in the directory he/she is started git from.

Eric, ack/nack?

Nack, here's (hopefully) a better patch.

David: agree/disagree?

From 62648d512a27a546707da160c939d665e6da57b4 Mon Sep 17 00:00:00 2001
From: Eric Wong <[email protected]>
Date: Thu, 18 Oct 2007 03:29:28 -0700
Subject: [PATCH] git-svn: make the output of "git svn clone" less confusing
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Original patch by David Kågedal:

Quoted 7 lines

The problem is that the first thing it prints is

Initialized empty Git repository in .git/

even if actually created a subdirectory and changed into it first. But to the user, it looks like it is creating a .git/ dir in the directory he/she is started git from.

Instead of using a relative path, I'm capturing the output of git-init and adding the absolute path to it.

---

I've actually just noticed that setting GIT_DIR= before running git-svn clone is very broken, and I probably won't get a chance to fix it for at least 24 hours (if I'm even awake)...

Johannes/Benoit/all: git-svn submodules will probably have to wait till the weekend...

 git-svn.perl |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
git-svn.perl +4 -1
index 777e436..4873bad 100755
@@ -3,6 +3,7 @@
 # License: GPL v2 or later
 use warnings;
 use strict;
+use Cwd qw/getcwd/;
 use vars qw/	$AUTHOR $VERSION
 		$sha1 $sha1_short $_revision
 		$_q $_authors %users/;
@@ -272,7 +273,9 @@ sub do_git_init_db {
 				push @init_db, "--shared";
 			}
 		}
-		command_noisy(@init_db);
+		my $init_out = command(@init_db);
+		$init_out =~ s!(\.git)!getcwd .  "/$1"!e;
+		print $init_out, "\n";
 	}
 	my $set;
 	my $pfx = "svn-remote.$Git::SVN::default_repo_id";
Signature · 1 line
Eric Wong

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 14 lines · David Kågedal
Quoted 12 lines · Eric Wong
Quoted 10 lines · Shawn O. Pearce
Quoted 7 lines · David Kågedal

The problem is that the first thing it prints is

Initialized empty Git repository in .git/

even if actually created a subdirectory and changed into it first. But to the user, it looks like it is creating a .git/ dir in the directory he/she is started git from.

Eric, ack/nack?

Quoted 7 lines
Quoted 3 lines

Nack, here's (hopefully) a better patch.

David: agree/disagree?

I don't really like this. Now you added a dependency on exactly how git-init-db will format its output. So if e.g. it is updated to use the absolute path your patch will create bogus output.

Yes, it's quite ugly :/ I think the best solution would be to fix all
GIT_DIR= setting issues and getting git-svn to always respect it for init/clone/fetch (and tests, of course!). I probably won't get around to doing any of this until Friday night or Saturday (PST), however...

Shawn: feel free to ignore this series for now

Quoted 2 lines

Did you consider my suggestion of not doing the chdir befor running git-init-db?

That would likely break clone, and also this (from my message under the commit message).

Quoted 3 lines

I've actually just noticed that setting GIT_DIR= before running git-svn clone is very broken, and I probably won't get a chance to fix it for at least 24 hours (if I'm even awake)...

Signature · 1 line
Eric Wong