Re: [PATCH v2] git svn: info: correctly handle absolute path args

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]