From: Deskin Miller <deskinm@umich.edu>
To: Eric Wong <normalperson@yhbt.net>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH v2] git-svn: proper detection of bare repositories
Date: Thu, 6 Nov 2008 00:07:39 -0500 [thread overview]
Message-ID: <20081106050739.GA7713@euler> (raw)
In-Reply-To: <20081104083015.GA14405@untitled>
On Tue, Nov 04, 2008 at 12:30:15AM -0800, Eric Wong wrote:
> How about using git_cmd_try instead?
>
> The Error.pm try/catch stuff makes me a bit uncomfortable. I realize
> it's (unfortunately) in Git.pm; but I'd rather keep it confined there so
> we can more easily remove it later if someone were inclined.
Yeah, major thinko; I read the Git(3pm) manpage, looked at git_cmd_try, and for
some reason thought that it wasn't what I want. But it's exactly what I want.
Deskin Miller
-- 8< --
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>
---
git-svn.perl | 12 +++++++-----
t/t9100-git-svn-basic.sh | 9 +++++++++
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 56238da..829a323 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -214,11 +214,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 843a501..fdbc23a 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
--
1.6.0.3.524.g47d14
next prev parent reply other threads:[~2008-11-06 5:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-03 0:09 [RFC PATCH] git-svn: proper detection of bare repositories Deskin Miller
2008-11-04 8:30 ` Eric Wong
2008-11-06 5:07 ` Deskin Miller [this message]
2008-11-06 9:45 ` [PATCH v2] " Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081106050739.GA7713@euler \
--to=deskinm@umich.edu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=normalperson@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.