summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorBarry Wardell <barry.wardell@gmail.com>2013-01-21 01:22:02 +0000
committerEric Wong <normalperson@yhbt.net>2013-01-24 10:21:23 +0000
commitbc93ceb7c5ec959ad275f575a3c49ff491337a8b (patch)
tree32b9b793f3fe6fc9cec2e0af33340f3062c5e723 /git-svn.perl
parent1b67bef25606471817d9b0a61a923568de0daac8 (diff)
downloadgit-bc93ceb7c5ec959ad275f575a3c49ff491337a8b.tar.gz
git-svn: Simplify calculation of GIT_DIR
Since git-rev-parse already checks for the $GIT_DIR environment variable and that it returns an actual git repository, there is no need to repeat the checks again here. This also fixes a problem where git-svn did not work in cases where .git was a file with a gitdir: link. [ew: squashed test case, delay setting GIT_DIR until after `git rev-parse --cdup` to fix t9101, (thanks to Junio)] Signed-off-by: Barry Wardell <barry.wardell@gmail.com> Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl37
1 files changed, 14 insertions, 23 deletions
diff --git a/git-svn.perl b/git-svn.perl
index d0866946ce..b46795f593 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -61,8 +61,6 @@ my $cmd_dir_prefix = eval {
command_oneline([qw/rev-parse --show-prefix/], STDERR => 0)
} || '';
-my $git_dir_user_set = 1 if defined $ENV{GIT_DIR};
-$ENV{GIT_DIR} ||= '.git';
$Git::SVN::Ra::_log_window_size = 100;
if (! exists $ENV{SVN_SSH} && exists $ENV{GIT_SSH}) {
@@ -327,27 +325,20 @@ for (my $i = 0; $i < @ARGV; $i++) {
};
# make sure we're always running at the top-level working directory
-unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
- unless (-d $ENV{GIT_DIR}) {
- if ($git_dir_user_set) {
- die "GIT_DIR=$ENV{GIT_DIR} explicitly set, ",
- "but it is not a directory\n";
- }
- my $git_dir = delete $ENV{GIT_DIR};
- 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 ",
- "'$cdup'\n";
- }
- $ENV{GIT_DIR} = $git_dir;
- }
+if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
+ $ENV{GIT_DIR} ||= ".git";
+} else {
+ my ($git_dir, $cdup);
+ git_cmd_try {
+ $git_dir = command_oneline([qw/rev-parse --git-dir/]);
+ } "Unable to find .git directory\n";
+ git_cmd_try {
+ $cdup = command_oneline(qw/rev-parse --show-cdup/);
+ chomp $cdup if ($cdup);
+ $cdup = "." unless ($cdup && length $cdup);
+ } "Already at toplevel, but $git_dir not found\n";
+ $ENV{GIT_DIR} = $git_dir;
+ chdir $cdup or die "Unable to chdir up to '$cdup'\n";
$_repository = Git->repository(Repository => $ENV{GIT_DIR});
}