git-svn: make it play nicely with submodules
It's a simple matter of opening the directory specified in the gitfile. [ew: tweaked check to avoid open() on directories] Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Eric Wong <normalperson@yhbt.net>
Ramkumar Ramachandra committed
Jan 10, 2015 at 09:55 UTC
a94655dcfedc6b266ba32a3d32b0d52a1ce6a928
1 file changed
+6
git-svn.perl
+6
@@ -337,6 +337,12 @@ for (my $i = 0; $i < @ARGV; $i++) {
337
# make sure we're always running at the top-level working directory
338
if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
339
$ENV{GIT_DIR} ||= ".git";
340
+ # catch the submodule case
341
+ if (-f $ENV{GIT_DIR}) {
342
+ open(my $fh, '<', $ENV{GIT_DIR}) or
343
+ die "failed to open $ENV{GIT_DIR}: $!\n";
344
+ $ENV{GIT_DIR} = $1 if <$fh> =~ /^gitdir: (.+)$/;
345
+ }
346
} else {
347
my ($git_dir, $cdup);
348
git_cmd_try {