Re: [PATCH 2/2] builtin/blame: highlight recently changed lines
- From
Stefan Beller <sbeller@google.com>
- Date
- Jun 11, 2018, 23:56 UTC
- Message-ID
- <CAGZ79kYLgKEJtMG+S_A3TnLN6u-r04BHGBF7yENVLNsvgJr8Ag@mail.gmail.com>
- In-Reply-To
- <737e4f2e-9896-0119-2c43-655ac29fe018@web.de>
On Sat, Jun 9, 2018 at 4:26 AM René Scharfe <l.s.r@web.de> wrote:
Show 13 quoted lines
>
> Am 17.04.2018 um 23:30 schrieb Stefan Beller:
> > +static void parse_color_fields(const char *s)
> > +{
> > + struct string_list l = STRING_LIST_INIT_DUP;
> > + struct string_list_item *item;
> > + enum { EXPECT_DATE, EXPECT_COLOR } next = EXPECT_COLOR;
> > +
> > + colorfield_nr = 0;
> > +
> > + /* Ideally this would be stripped and split at the same time? */
>
> Why? Both approxidate() and color_parse() handle spaces.I think that comment is stale; I remember experimenting with different internal structs to write a parser until I came up with this implementation. It is a left over.
> This adds a minor memory leak; fix below.
Thanks!
Show 22 quoted lines
> -- >8 --
> Subject: [PATCH] blame: release string_list after use in parse_color_fields()
>
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---
> builtin/blame.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/builtin/blame.c b/builtin/blame.c
> index 4202584f97..3295718841 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -411,6 +411,7 @@ static void parse_color_fields(const char *s)
> die (_("must end with a color"));
>
> colorfield[colorfield_nr].hop = TIME_MAX;
> + string_list_clear(&l, 0);
> }
>
> static void setup_default_color_by_age(void)
> --
> 2.17.1