[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/6] realpath: let --relative-to default to --relative-base
From: |
Eric Blake |
Subject: |
Re: [PATCH 4/6] realpath: let --relative-to default to --relative-base |
Date: |
Wed, 14 Mar 2012 15:43:56 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1 |
On 03/14/2012 03:38 PM, Pádraig Brady wrote:
> On 03/14/2012 08:38 PM, Eric Blake wrote:
>> Most of the time, if someone wants to filter which paths are
>> relative while leaving all others absolute, they also want to
>> to the filtering based on the same --relative-to directory.
s/to/do/ before this gets applied
> I wonder is it worth short circuiting some later code
> when relative_to == relative_base, like:
>
> diff --git a/src/realpath.c b/src/realpath.c
> index 7834c62..c3f5809 100644
> --- a/src/realpath.c
> +++ b/src/realpath.c
> @@ -183,7 +183,8 @@ relpath (const char *can_fname)
> if (can_relative_base)
> {
> if (!path_prefix (can_relative_base, can_fname)
> - || !path_prefix (can_relative_base, can_relative_to))
> + || ((can_relative_base != can_relative_to)
> + && !path_prefix (can_relative_base, can_relative_to)))
Indeed, that would save some string operations on a (potentially long)
name through multiple command line arguments. I'll squash this in if
you like the series.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [PATCH 0/6] realpath cleanups, Eric Blake, 2012/03/14
- [PATCH 5/6] doc: clarify current realpath --relative-base behavior, Eric Blake, 2012/03/14
- [PATCH 2/6] realpath: fix problems with root handling, Eric Blake, 2012/03/14
- [PATCH 6/6] realpath: let --relative-base work even as child of --relative-to, Eric Blake, 2012/03/14
- [PATCH 1/6] test: expose recent gnulib canonicalize bug, Eric Blake, 2012/03/14
- [PATCH 4/6] realpath: let --relative-to default to --relative-base, Eric Blake, 2012/03/14
- [PATCH 3/6] tests: cover more realpath scenarios, Eric Blake, 2012/03/14
- Re: [PATCH 0/6] realpath cleanups, Pádraig Brady, 2012/03/14