Re: [PATCH v4 3/4] setup: Add 'abspath_part_inside_repo' function
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 2, 2014, 12:15 UTC
- Message-ID
- <CACsJy8AWMr95fTS_TRkPiU_ety-KWYuimKj+SUAt-BRoAU0JTA@mail.gmail.com>
- In-Reply-To
- <20140202111330.GB14729@mule>
On Sun, Feb 2, 2014 at 6:13 PM, Martin Erik Werner <martinerikwerner@gmail.com> wrote:
Show 14 quoted lines
> 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) {
> if (path[wtlen] == '/')
> memmove(path, path + wtlen + 1, len - wtlen);
> - else
> + else if (path[wtlen - 1] == '/' || path[wtlen] == '\0')
> /* work tree is the root, or the whole path */
> memmove(path, path + wtlen, len - wtlen + 1);
> + else
> + return -1;No, you can't return here. "/abc/defghi" might actually be a symlink to "/abc/def". If it does not match, let the following loop handle it.
-- Duy