Re: [PATCH 07/25] list-files: add tag to each entry, filter duplicate tags
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Apr 6, 2015, 21:32 UTC
- Message-ID
- <CAPig+cS=41Y+c-vz7h8=jWEw_9ZKWT4JJ-boERCMyRzq=x_p+g@mail.gmail.com>
- In-Reply-To
- <1428328354-14897-8-git-send-email-pclouds@gmail.com>
On Mon, Apr 6, 2015 at 9:52 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 26 quoted lines
> All entries have a two-letter tag. If all entries have the same tags,
> tags are not displayed.
>
> The outcome before and after this patch is the same. But it will be
> useful in future when there are more than one type of entry.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/builtin/list-files.c b/builtin/list-files.c
> index 51ff19d..ec9ca17 100644
> --- a/builtin/list-files.c
> +++ b/builtin/list-files.c
> @@ -52,10 +56,61 @@ static void populate_cached_entries(struct item_list *result,
> +static void cleanup_tags(struct item_list *result)
> +{
> + int i, same_1 = 1, same_2 = 1;
> +
> + if (!show_tag) {
> + result->tag_pos = 0;
> + result->tag_len = 0;
> + return;
> + }
> [...]
> +}
> +
> +/* this is similar to quote_path_relative() except it does not clear sb */This comment is a bit confusing since it talks about 'sb', which is a local variable, rather than the intended 'out'. Perhaps rephrase:
/* similar to quote_path_relative() but does not clear 'out' */
Show 13 quoted lines
> +static void quote_item(struct strbuf *out, const struct item *item)
> +{
> + static struct strbuf sb = STRBUF_INIT;
> + const char *rel;
> +
> + strbuf_reset(&sb);
> + rel = relative_path(item->path, prefix, &sb);
> + quote_c_style(rel, out, NULL, 0);
> +}
> +
> static void display(const struct item_list *result)
> {
> struct strbuf quoted = STRBUF_INIT;