aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeskin Miller <deskinm@umich.edu>2008-11-06 00:07:39 -0500
committerEric Wong <normalperson@yhbt.net>2008-11-13 22:33:59 -0800
commitfe4003f6308b88bcc44a989f12e1baddd97f22d4 (patch)
treefa76d099401455c6ea3ed146fccc24a5eb461948
parent16fc08e2d86dad152194829d21bc55b2ef0c8fb1 (diff)
downloadgit-fe4003f6308b88bcc44a989f12e1baddd97f22d4.tar.gz
git-fe4003f6308b88bcc44a989f12e1baddd97f22d4.tar.xz
git-svn: proper detection of bare repositories
When in a bare repository (or .git, for that matter), git-svn would fail to initialise properly, since git rev-parse --show-cdup would not output anything. However, git rev-parse --show-cdup actually returns an error code if it's really not in a git directory. Fix the issue by checking for an explicit error from git rev-parse, and setting $git_dir appropriately if instead it just does not output. Signed-off-by: Deskin Miller <deskinm@umich.edu> Acked-by: Eric Wong <normalperson@yhbt.net>
-rwxr-xr-xgit-svn.perl12
-rwxr-xr-xt/t9100-git-svn-basic.sh9
2 files changed, 16 insertions, 5 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 2abb7b593..86075ec61 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -223,11 +223,13 @@ unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
"but it is not a directory\n";
}
my $git_dir = delete $ENV{GIT_DIR};
- chomp(my $cdup = command_oneline(qw/rev-parse --show-cdup/));
- unless (length $cdup) {
- die "Already at toplevel, but $git_dir ",
- "not found '$cdup'\n";
- }
+ my $cdup = undef;
+ git_cmd_try {
+ $cdup = command_oneline(qw/rev-parse --show-cdup/);
+ $git_dir = '.' unless ($cdup);
+ chomp $cdup if ($cdup);
+ $cdup = "." unless ($cdup && length $cdup);
+ } "Already at toplevel, but $git_dir not found\n";
chdir $cdup or die "Unable to chdir up to '$cdup'\n";
unless (-d $git_dir) {
die "$git_dir still not found after going to ",
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 9b238c329..bb921af56 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -265,4 +265,13 @@ test_expect_success 'able to set-tree to a subdirectory' "
test -z \"\`git diff refs/heads/my-bar refs/remotes/bar\`\"
"
+test_expect_success 'git-svn works in a bare repository' '
+ mkdir bare-repo &&
+ ( cd bare-repo &&
+ git init --bare &&
+ GIT_DIR=. git svn init "$svnrepo" &&
+ git svn fetch ) &&
+ rm -rf bare-repo
+ '
+
test_done