Re: [PATCH v2 2/3] difftool: avoid double slashes in symlink targets

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

 



John Keeping <john@xxxxxxxxxxxxx> writes:

> When we add tests for symlinks in "git difftool --dir-diff" it's easier
> to check the target path if we don't have to worry about double slashes
> separating directories.  Remove the trailing slash (if present) from
> $workdir before creating the symlinks in order to avoid this.

Yup, and it is a good basic hygiene even without tests that expect
the exact pathnames.

The code would work even when your $workdir is at the root of the
filesystem; the patch looks good.

Thanks.

> Signed-off-by: John Keeping <john@xxxxxxxxxxxxx>
> ---
>  git-difftool.perl | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/git-difftool.perl b/git-difftool.perl
> index 12231fb..e594f9c 100755
> --- a/git-difftool.perl
> +++ b/git-difftool.perl
> @@ -209,7 +209,9 @@ EOF
>  	delete($ENV{GIT_INDEX_FILE});
>  
>  	# Changes in the working tree need special treatment since they are
> -	# not part of the index
> +	# not part of the index. Remove any trailing slash from $workdir
> +	# before starting to avoid double slashes in symlink targets.
> +	$workdir =~ s|/$||;
>  	for my $file (@working_tree) {
>  		my $dir = dirname($file);
>  		unless (-d "$rdir/$dir") {
--
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]