git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: René ScharfeNext: Junio C Hamano
Message 15 of 18 in “blame: color line by commit”
  1. 0/2 blame: color line by commitStefan Beller, Apr 16, 2018
  2. 1/2 builtin/blame: dim uninteresting metadata linesStefan Beller, Apr 16, 2018
  3. Junio C HamanoApr 17, 2018
  4. Stefan BellerApr 17, 2018
  5. 2/2 builtin/blame: highlight recently changed linesStefan Beller, Apr 16, 2018
  6. Junio C HamanoApr 17, 2018
  7. Junio C HamanoApr 17, 2018
  8. Stefan BellerApr 17, 2018
  9. Stefan BellerApr 17, 2018
  10. 1/2 builtin/blame: dim uninteresting metadata linesStefan Beller, Apr 17, 2018
  11. 2/2 builtin/blame: highlight recently changed linesStefan Beller, Apr 17, 2018
  12. Eric SunshineApr 17, 2018
  13. Junio C HamanoApr 18, 2018
  14. René ScharfeJun 9, 2018
  15. Stefan BellerJun 11, 2018
  16. Junio C HamanoJun 14, 2018
  17. Junio C HamanoApr 18, 2018
  18. Junio C HamanoApr 18, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.