summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorDeskin Miller <deskinm@umich.edu>2008-11-06 05:07:39 (GMT)
committerEric Wong <normalperson@yhbt.net>2008-11-06 09:39:41 (GMT)
commit6e5121f26e95af02d2bbd6a982e44f16e74a67ce (patch)
treef945fed09aee92123cf4153be698e66004a3d0ec /git-svn.perl
parentaab57205515d9a74fe20cd51c509f65757b97a66 (diff)
downloadgit-6e5121f26e95af02d2bbd6a982e44f16e74a67ce.zip
git-6e5121f26e95af02d2bbd6a982e44f16e74a67ce.tar.gz
git-6e5121f26e95af02d2bbd6a982e44f16e74a67ce.tar.bz2
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>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl12
1 files changed, 7 insertions, 5 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 2abb7b5..86075ec 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 ",