On Monday, March 9, 2015, Nguyễn Thái Ngọc Duy <[email protected]> wrote:
> The index does not store directories explicitly (except submodules) so
> we have to figure them out from file list when output lis depth-limited.
s/lis/is/
> The function add_directory() can generate duplicate entries, which is
> cleaned up before displaying.
> ---
> diff --git a/builtin/list-files.c b/builtin/list-files.c
> index 9a55ea6..dc865a1 100644
> --- a/builtin/list-files.c
> +++ b/builtin/list-files.c
> @@ -43,6 +45,51 @@ static void add_one(struct string_list *result, const char
> *name,
> item->util = (char *)name;
> }
>
> +static int add_directory(struct string_list *result,
> + const char *name)
> +{
> + struct strbuf sb = STRBUF_INIT;
> + const char *p;
> +
> + strbuf_add(&sb, name, strlen(name));
strbuf_addstr() perhaps?
> + while (sb.len && (p = strrchr(sb.buf, '/')) != NULL) {
> + strbuf_setlen(&sb, p - sb.buf);
> + if (!match_pathspec(&pathspec, sb.buf, sb.len, 0, NULL, 1))
> + continue;
> + add_one(result, sb.buf, " ");
> + /*
> + * sb.buf is leaked, but because this command is
> + * short-lived anyway so it does not matter much
> + */
> + return 1;
> + }
> + strbuf_release(&sb);
> + return 0;
> +}
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html