提交 6e5121f2 编写于 作者: D Deskin Miller 提交者: Eric Wong

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: NDeskin Miller <deskinm@umich.edu>
Acked-by: NEric Wong <normalperson@yhbt.net>
上级 aab57205
...@@ -223,11 +223,13 @@ BEGIN ...@@ -223,11 +223,13 @@ BEGIN
"but it is not a directory\n"; "but it is not a directory\n";
} }
my $git_dir = delete $ENV{GIT_DIR}; my $git_dir = delete $ENV{GIT_DIR};
chomp(my $cdup = command_oneline(qw/rev-parse --show-cdup/)); my $cdup = undef;
unless (length $cdup) { git_cmd_try {
die "Already at toplevel, but $git_dir ", $cdup = command_oneline(qw/rev-parse --show-cdup/);
"not found '$cdup'\n"; $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"; chdir $cdup or die "Unable to chdir up to '$cdup'\n";
unless (-d $git_dir) { unless (-d $git_dir) {
die "$git_dir still not found after going to ", die "$git_dir still not found after going to ",
......
...@@ -265,4 +265,13 @@ test_expect_success 'able to set-tree to a subdirectory' " ...@@ -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 -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 test_done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册