On Mon, Jun 19, 2017 at 11:50 PM, Prathamesh Chavan <[email protected]> wrote:
> +static char *get_up_path(const char *path)
> +{
> + int i = count_slashes(path);
> + struct strbuf sb = STRBUF_INIT;
> +
> + while (i--)
> + strbuf_addstr(&sb, "../");
> +
> + /*
> + *Check if 'path' ends with slash or not
> + *for having the same output for dir/sub_dir
> + *and dir/sub_dir/
> + */
> + if (!is_dir_sep(path[i - 1]))
i is always 0 here, as we decrease it until it gets to 0 above.
> + strbuf_addstr(&sb, "../");
> +
> + return strbuf_detach(&sb, NULL);
> +}