From: Johannes Sixt Date: Sun, 07 Sep 2014 08:57:43 GMT Subject: Re: [PATCH v2] git svn: info: correctly handle absolute path args Message-ID: <540C1E07.7030105@kdbg.org> In-Reply-To: <20140907080626.GA6273@dcvr.yhbt.net> Am 07.09.2014 10:06, schrieb Eric Wong: > diff --git a/git-svn.perl b/git-svn.perl > index 1f41ee1..47cd6ea 100755 > --- a/git-svn.perl > +++ b/git-svn.perl > @@ -1477,10 +1477,20 @@ sub cmd_commit_diff { > } > } > > - > sub cmd_info { > - my $path = canonicalize_path(defined($_[0]) ? $_[0] : "."); > - my $fullpath = canonicalize_path($cmd_dir_prefix . $path); > + my $path_arg = defined($_[0]) ? $_[0] : '.'; > + my $path = $path_arg; > + if ($path =~ m!\A/!) { There must be a more portable way to check for an absolute path. Think of DOS-style paths... > + my $toplevel = eval { > + my @cmd = qw/rev-parse --show-toplevel/; > + command_oneline(\@cmd, STDERR => 0); > + }; > + $path = canonicalize_path($path); > + $path =~ s!\A\Q$toplevel\E/?!!; > + $path = canonicalize_path($path); > + } else { > + $path = canonicalize_path($cmd_dir_prefix . $path); > + } > if (exists $_[1]) { > die "Too many arguments specified\n"; > } -- Hannes