Skip to contentSkip to conversation

git-svn: allow --version to work anywhere

RFC In review Eric Wong 2 participants 6 messages Jul 20, 2016 – Jul 28, 2016

lore
Share & tools
lore

Eric Wong

author
#0 lore raw

RFC 1/1 git-svn: allow --version to work anywhere

Checking the version of the installed SVN libraries should not require a git repository at all. This matches the behavior of "git --version".

Add a test for "git svn help" for the same behavior while we're at it, too.

---
I'm hoping "cd /" in the test will always succeed; but I suppose non-*nix systems might fail, here.

And maybe a BOFH did "chmod 700 /" :(

Anyways this is sitting in master of git://bogomips.org/git-svn.git

 git-svn.perl             | 4 ++--
 t/t9100-git-svn-basic.sh | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
git-svn.perl +2 -2
index f609e54..4d41d22 100755
@@ -339,7 +339,7 @@ if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 			die "failed to open $ENV{GIT_DIR}: $!\n";
 		$ENV{GIT_DIR} = $1 if <$fh> =~ /^gitdir: (.+)$/;
 	}
-} else {
+} elsif ($cmd) {
 	my ($git_dir, $cdup);
 	git_cmd_try {
 		$git_dir = command_oneline([qw/rev-parse --git-dir/]);
@@ -356,7 +356,7 @@ if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 
 my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
 
-read_git_config(\%opts);
+read_git_config(\%opts) if $ENV{GIT_DIR};
 if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {
 	Getopt::Long::Configure('pass_through');
 }
t/t9100-git-svn-basic.sh +8 -0
index 28082b1..10408d0 100755
@@ -19,6 +19,14 @@ case "$GIT_SVN_LC_ALL" in
 	;;
 esac
 
+test_expect_success 'git svn --version works anywhere' '
+	( cd / || exit 0; git svn --version )
+'
+
+test_expect_success 'git svn help works anywhere' '
+	( cd / || exit 0; git svn help )
+'
+
 test_expect_success \
     'initialize git svn' '
 	mkdir import &&
Signature · 1 line
EW
#1 lore raw
Quoted 11 lines · Eric Wong

Checking the version of the installed SVN libraries should not require a git repository at all. This matches the behavior of "git --version".

Add a test for "git svn help" for the same behavior while we're at it, too.

---
I'm hoping "cd /" in the test will always succeed; but I suppose non-*nix systems might fail, here.

How about digging a few levels of directory hierarchy, exporting GIT_CEILING_DIRECTORIES so that we won't find any repository and going there to run these tests?

Quoted 49 lines

And maybe a BOFH did "chmod 700 /" :(

Anyways this is sitting in master of git://bogomips.org/git-svn.git

 git-svn.perl             | 4 ++--
 t/t9100-git-svn-basic.sh | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)
git-svn.perl +2 -2
index f609e54..4d41d22 100755
@@ -339,7 +339,7 @@ if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 			die "failed to open $ENV{GIT_DIR}: $!\n";
 		$ENV{GIT_DIR} = $1 if <$fh> =~ /^gitdir: (.+)$/;
 	}
-} else {
+} elsif ($cmd) {
 	my ($git_dir, $cdup);
 	git_cmd_try {
 		$git_dir = command_oneline([qw/rev-parse --git-dir/]);
@@ -356,7 +356,7 @@ if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 
 my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
 
-read_git_config(\%opts);
+read_git_config(\%opts) if $ENV{GIT_DIR};
 if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {
 	Getopt::Long::Configure('pass_through');
 }
t/t9100-git-svn-basic.sh +8 -0
index 28082b1..10408d0 100755
@@ -19,6 +19,14 @@ case "$GIT_SVN_LC_ALL" in
 	;;
 esac
 
+test_expect_success 'git svn --version works anywhere' '
+	( cd / || exit 0; git svn --version )
+'
+
+test_expect_success 'git svn help works anywhere' '
+	( cd / || exit 0; git svn help )
+'
+
 test_expect_success \
     'initialize git svn' '
 	mkdir import &&
author
#2 lore raw

PATCH 1/1 git-svn: allow --version to work anywhere

Quoted 7 lines · Junio C Hamano
Quoted 2 lines · Eric Wong

I'm hoping "cd /" in the test will always succeed; but I suppose non-*nix systems might fail, here.

How about digging a few levels of directory hierarchy, exporting GIT_CEILING_DIRECTORIES so that we won't find any repository and going there to run these tests?

Ah, thanks; I missed that.

Repushed my master in case it's a convenient time to pull.

The following changes since commit 29493589e97a2de0c4c1c314f61ccafaee3b5caf:

archive-tar: huge offset and future timestamps would not work on 32-bit (2016-07-15 10:51:55 -0700)

are available in the git repository at:

git://bogomips.org/git-svn.git master

for you to fetch changes up to c0071ae5dc1c610ab3791ece7ccf7d4772fde151:

  git-svn: allow --version to work anywhere (2016-07-22 20:38:11 +0000)

----------------------------------------------------------------
Eric Wong (2):
git-svn: document svn.authorsProg in config
git-svn: allow --version to work anywhere

 Documentation/git-svn.txt |  3 +++
 git-svn.perl              |  4 ++--
 t/t9100-git-svn-basic.sh  | 19 +++++++++++++++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

-----8<-----
Subject: [PATCH] git-svn: allow --version to work anywhere

Checking the version of the installed SVN libraries should not require a git repository at all. This matches the behavior of "git --version".

Add a test for "git svn help" for the same behavior while we're at it, too.

---
 git-svn.perl             |  4 ++--
 t/t9100-git-svn-basic.sh | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
git-svn.perl +2 -2
index f609e54..4d41d22 100755
@@ -339,7 +339,7 @@ if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 			die "failed to open $ENV{GIT_DIR}: $!\n";
 		$ENV{GIT_DIR} = $1 if <$fh> =~ /^gitdir: (.+)$/;
 	}
-} else {
+} elsif ($cmd) {
 	my ($git_dir, $cdup);
 	git_cmd_try {
 		$git_dir = command_oneline([qw/rev-parse --git-dir/]);
@@ -356,7 +356,7 @@ if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
 
 my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
 
-read_git_config(\%opts);
+read_git_config(\%opts) if $ENV{GIT_DIR};
 if ($cmd && ($cmd eq 'log' || $cmd eq 'blame')) {
 	Getopt::Long::Configure('pass_through');
 }
t/t9100-git-svn-basic.sh +19 -0
index 28082b1..ab6593b 100755
@@ -19,6 +19,25 @@ case "$GIT_SVN_LC_ALL" in
 	;;
 esac
 
+deepdir=nothing-above
+ceiling=$PWD
+
+test_expect_success 'git svn --version works anywhere' '
+	mkdir -p "$deepdir" && (
+		export GIT_CEILING_DIRECTORIES="$ceiling" &&
+		cd "$deepdir" &&
+		git svn --version
+	)
+'
+
+test_expect_success 'git svn help works anywhere' '
+	mkdir -p "$deepdir" && (
+		export GIT_CEILING_DIRECTORIES="$ceiling" &&
+		cd "$deepdir" &&
+		git svn help
+	)
+'
+
 test_expect_success \
     'initialize git svn' '
 	mkdir import &&
Signature · 1 line
EW
#3 lore raw
Quoted 6 lines · Eric Wong

Repushed my master in case it's a convenient time to pull.

The following changes since commit 29493589e97a2de0c4c1c314f61ccafaee3b5caf:

archive-tar: huge offset and future timestamps would not work on 32-bit (2016-07-15 10:51:55 -0700)

Quoted 7 lines

are available in the git repository at:

git://bogomips.org/git-svn.git master

for you to fetch changes up to c0071ae5dc1c610ab3791ece7ccf7d4772fde151:

  git-svn: allow --version to work anywhere (2016-07-22 20:38:11 +0000)

Thanks, pulled.

#4 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 8 lines · Eric Wong

Repushed my master in case it's a convenient time to pull.

The following changes since commit 29493589e97a2de0c4c1c314f61ccafaee3b5caf:

archive-tar: huge offset and future timestamps would not work on 32-bit (2016-07-15 10:51:55 -0700)

are available in the git repository at:

Quoted 7 lines
Quoted 5 lines

git://bogomips.org/git-svn.git master

for you to fetch changes up to c0071ae5dc1c610ab3791ece7ccf7d4772fde151:

  git-svn: allow --version to work anywhere (2016-07-22 20:38:11 +0000)

Thanks, pulled.

I was too deep in today's integration cycle to waste half-day's work, so I added this hotfix after the merge, directly on 'master'.

-- >8 --
Subject: [PATCH] t9100: portability fix

Do not say "export VAR=VAL"; "VAR=VAL && export VAR" is always more portable.

---
 t/t9100-git-svn-basic.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
t/t9100-git-svn-basic.sh +4 -2
index ab6593b..d29f601 100755
@@ -24,7 +24,8 @@ ceiling=$PWD
 
 test_expect_success 'git svn --version works anywhere' '
 	mkdir -p "$deepdir" && (
-		export GIT_CEILING_DIRECTORIES="$ceiling" &&
+		GIT_CEILING_DIRECTORIES="$ceiling" &&
+		export GIT_CEILING_DIRECTORIES &&
 		cd "$deepdir" &&
 		git svn --version
 	)
@@ -32,7 +33,8 @@ test_expect_success 'git svn --version works anywhere' '
 
 test_expect_success 'git svn help works anywhere' '
 	mkdir -p "$deepdir" && (
-		export GIT_CEILING_DIRECTORIES="$ceiling" &&
+		GIT_CEILING_DIRECTORIES="$ceiling" &&
+		export GIT_CEILING_DIRECTORIES &&
 		cd "$deepdir" &&
 		git svn help
 	)
Signature · 1 line
2.9.2-662-gbb82c05
author
#5 lore raw
Quoted 4 lines · Junio C Hamano

Subject: [PATCH] t9100: portability fix

Do not say "export VAR=VAL"; "VAR=VAL && export VAR" is always more portable.

Oops, sorry I should've caught that :x