|
61 | 61 | command_oneline([qw/rev-parse --show-prefix/], STDERR => 0)
|
62 | 62 | } || '';
|
63 | 63 |
|
64 |
| -my $git_dir_user_set = 1 if defined $ENV{GIT_DIR}; |
65 |
| -$ENV{GIT_DIR} ||= '.git'; |
66 | 64 | $Git::SVN::Ra::_log_window_size = 100;
|
67 | 65 |
|
68 | 66 | if (! exists $ENV{SVN_SSH} && exists $ENV{GIT_SSH}) {
|
@@ -327,27 +325,20 @@ package main;
|
327 | 325 | };
|
328 | 326 |
|
329 | 327 | # make sure we're always running at the top-level working directory
|
330 |
| -unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) { |
331 |
| - unless (-d $ENV{GIT_DIR}) { |
332 |
| - if ($git_dir_user_set) { |
333 |
| - die "GIT_DIR=$ENV{GIT_DIR} explicitly set, ", |
334 |
| - "but it is not a directory\n"; |
335 |
| - } |
336 |
| - my $git_dir = delete $ENV{GIT_DIR}; |
337 |
| - my $cdup = undef; |
338 |
| - git_cmd_try { |
339 |
| - $cdup = command_oneline(qw/rev-parse --show-cdup/); |
340 |
| - $git_dir = '.' unless ($cdup); |
341 |
| - chomp $cdup if ($cdup); |
342 |
| - $cdup = "." unless ($cdup && length $cdup); |
343 |
| - } "Already at toplevel, but $git_dir not found\n"; |
344 |
| - chdir $cdup or die "Unable to chdir up to '$cdup'\n"; |
345 |
| - unless (-d $git_dir) { |
346 |
| - die "$git_dir still not found after going to ", |
347 |
| - "'$cdup'\n"; |
348 |
| - } |
349 |
| - $ENV{GIT_DIR} = $git_dir; |
350 |
| - } |
| 328 | +if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) { |
| 329 | + $ENV{GIT_DIR} ||= ".git"; |
| 330 | +} else { |
| 331 | + my ($git_dir, $cdup); |
| 332 | + git_cmd_try { |
| 333 | + $git_dir = command_oneline([qw/rev-parse --git-dir/]); |
| 334 | + } "Unable to find .git directory\n"; |
| 335 | + git_cmd_try { |
| 336 | + $cdup = command_oneline(qw/rev-parse --show-cdup/); |
| 337 | + chomp $cdup if ($cdup); |
| 338 | + $cdup = "." unless ($cdup && length $cdup); |
| 339 | + } "Already at toplevel, but $git_dir not found\n"; |
| 340 | + $ENV{GIT_DIR} = $git_dir; |
| 341 | + chdir $cdup or die "Unable to chdir up to '$cdup'\n"; |
351 | 342 | $_repository = Git->repository(Repository => $ENV{GIT_DIR});
|
352 | 343 | }
|
353 | 344 |
|
|
0 commit comments