Re: [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function

2014-02-02 Thread Torsten Bögershausen
> >> Another comment: >> The "raw" comparison with '/' is probably working well on all >> POSIX/Linux/Unix systems. >> >> To be more portable, the macro >> is_dir_sep() >> can be used: >> >> if (is_dir_sep(path[wtlen])) > > Since the path is already normalized by 'normalize_path_copy_len' which >

Re: [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function

2014-02-02 Thread Duy Nguyen
On Sun, Feb 2, 2014 at 6:13 PM, Martin Erik Werner wrote: > diff --git a/setup.c b/setup.c > index 2270bd4..5817875 100644 > --- a/setup.c > +++ b/setup.c > @@ -32,9 +32,11 @@ static inline int abspath_part_inside_repo(char *path) > if (strncmp(path, work_tree, wtlen) == 0) { >

Re: [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function

2014-02-02 Thread Martin Erik Werner
On Sun, Feb 02, 2014 at 12:37:16PM +0100, Torsten Bögershausen wrote: > On 2014-02-02 12.21, David Kastrup wrote: > > Martin Erik Werner writes: > > > >> On Sun, Feb 02, 2014 at 09:19:04AM +0700, Duy Nguyen wrote: > >>> On Sun, Feb 2, 2014 at 8:59 AM, Martin Erik Werner > >>> wrote: > +

Re: [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function

2014-02-02 Thread Torsten Bögershausen
On 2014-02-02 12.21, David Kastrup wrote: > Martin Erik Werner writes: > >> On Sun, Feb 02, 2014 at 09:19:04AM +0700, Duy Nguyen wrote: >>> On Sun, Feb 2, 2014 at 8:59 AM, Martin Erik Werner >>> wrote: + /* check if work tree is already the prefix */ + if (strncmp(path, wor

Re: [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function

2014-02-02 Thread David Kastrup
Martin Erik Werner writes: > On Sun, Feb 02, 2014 at 09:19:04AM +0700, Duy Nguyen wrote: >> On Sun, Feb 2, 2014 at 8:59 AM, Martin Erik Werner >> wrote: >> > + /* check if work tree is already the prefix */ >> > + if (strncmp(path, work_tree, wtlen) == 0) { >> > + if (p

Re: [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function

2014-02-02 Thread Martin Erik Werner
On Sun, Feb 02, 2014 at 09:19:04AM +0700, Duy Nguyen wrote: > On Sun, Feb 2, 2014 at 8:59 AM, Martin Erik Werner > wrote: > > + /* check if work tree is already the prefix */ > > + if (strncmp(path, work_tree, wtlen) == 0) { > > + if (path[wtlen] == '/') > > +

Re: [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function

2014-02-01 Thread Duy Nguyen
On Sun, Feb 2, 2014 at 9:19 AM, Duy Nguyen wrote: >> + /* check whole path */ >> + if (strcmp(real_path(path0), work_tree) == 0) { >> + *path0 = '\0'; >> + return 0; >> + } > > I think this is already handled by the "check if work tree is already > the

Re: [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function

2014-02-01 Thread Duy Nguyen
On Sun, Feb 2, 2014 at 8:59 AM, Martin Erik Werner wrote: > + /* check if work tree is already the prefix */ > + if (strncmp(path, work_tree, wtlen) == 0) { > + if (path[wtlen] == '/') > + memmove(path, path + wtlen + 1, len - wtlen); > +

[PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function

2014-02-01 Thread Martin Erik Werner
In order to extract the part of an absolute path which lies inside the repo, it is not possible to directly use real_path, since that would dereference symlinks both outside and inside the work tree. Add an 'abspath_part_inside_repo' function which first checks if the work tree is already the pref