* [PATCH] git-svn: make it play nicely with submodules
@ 2015-01-10 14:55 Ramkumar Ramachandra
2015-01-10 22:11 ` Eric Wong
0 siblings, 1 reply; 3+ messages in thread
From: Ramkumar Ramachandra @ 2015-01-10 14:55 UTC (permalink / raw)
To: Git List; +Cc: Eric Wong
It's a simple matter of opening the directory specified in the gitfile.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
git-svn.perl | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/git-svn.perl b/git-svn.perl
index 6aa156c..8642783 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -337,6 +337,10 @@ for (my $i = 0; $i < @ARGV; $i++) {
# make sure we're always running at the top-level working directory
if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
$ENV{GIT_DIR} ||= ".git";
+ # catch the submodule case
+ if (open(my $fh, '<', $ENV{GIT_DIR})) {
+ $ENV{GIT_DIR} = $1 if <$fh> =~ /^gitdir: (.+)$/;
+ }
} else {
my ($git_dir, $cdup);
git_cmd_try {
--
2.2.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] git-svn: make it play nicely with submodules
2015-01-10 14:55 [PATCH] git-svn: make it play nicely with submodules Ramkumar Ramachandra
@ 2015-01-10 22:11 ` Eric Wong
2015-01-10 22:13 ` Ramkumar Ramachandra
0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2015-01-10 22:11 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: Git List
Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> +++ b/git-svn.perl
> @@ -337,6 +337,10 @@ for (my $i = 0; $i < @ARGV; $i++) {
> # make sure we're always running at the top-level working directory
> if ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
> $ENV{GIT_DIR} ||= ".git";
> + # catch the submodule case
> + if (open(my $fh, '<', $ENV{GIT_DIR})) {
> + $ENV{GIT_DIR} = $1 if <$fh> =~ /^gitdir: (.+)$/;
> + }
How portable is open on a directory? Perhaps it'd be better to
check if it's a file, first:
if (-f $ENV{GIT_DIR}) {
open(my $fh, '<', $ENV{GIT_DIR}) or
die "failed to open $ENV{GIT_DIR}: $!\n";
$ENV{GIT_DIR} = $1 if <$fh> =~ /^gitdir: (.+)$/;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] git-svn: make it play nicely with submodules
2015-01-10 22:11 ` Eric Wong
@ 2015-01-10 22:13 ` Ramkumar Ramachandra
0 siblings, 0 replies; 3+ messages in thread
From: Ramkumar Ramachandra @ 2015-01-10 22:13 UTC (permalink / raw)
To: Eric Wong; +Cc: Git List
Eric Wong wrote:
> How portable is open on a directory? Perhaps it'd be better to
> check if it's a file, first:
Sure, that works; feel free to fix it up locally before committing.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-10 22:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-10 14:55 [PATCH] git-svn: make it play nicely with submodules Ramkumar Ramachandra
2015-01-10 22:11 ` Eric Wong
2015-01-10 22:13 ` Ramkumar Ramachandra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).