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

Re: [tig] [PATCHv2 3/3] log: Colour the diff stat

From
Jonas Fonseca <jonas.fonseca@gmail.com>
Date
Apr 17, 2014, 00:44 UTC
Message-ID
<CAFuPQ1JbpNcun3hGps=hwaM14wOjF+iU9bsm9+ZmJvJV_Fea4Q@mail.gmail.com>
In-Reply-To
<1397426068-17439-4-git-send-email-a.kumar@alumni.iitm.ac.in>

On Sun, Apr 13, 2014 at 5:54 PM, Kumar Appaiah <a.kumar@alumni.iitm.ac.in> wrote:

Show 5 quoted lines
>
> This commit adds custom log_read and log_draw functions that utilize
> the diff stat drawing functions from the diff module. The absence of
> the triple hyphen separator prevents direct usage of the diff drawing
> functions directly.
See my comments below.
Show 61 quoted lines
> ---
>  src/log.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 53 insertions(+), 2 deletions(-)
>
> diff --git a/src/log.c b/src/log.c
> index 40c9a21..468f7c3 100644
> --- a/src/log.c
> +++ b/src/log.c
> @@ -23,6 +23,9 @@ struct log_state {
>          * up/down in the log view. */
>         int last_lineno;
>         enum line_type last_type;
> +       bool commit_title_read;
> +       bool after_commit_header;
> +       bool reading_diff_stat;
>  };
>
>  static void
> @@ -78,14 +81,62 @@ log_request(struct view *view, enum request request, struct line *line)
>         }
>  }
>
> +static bool
> +log_read(struct view *view, char *data)
> +{
> +       enum line_type type;
> +       struct log_state *state = view->private;
> +       size_t len;
> +
> +       if (!data)
> +               return TRUE;
> +
> +       type = get_line_type(data);
> +       len = strlen(data);
> +
> +       if (type == LINE_COMMIT)
> +               state->commit_title_read = TRUE;
> +       else if (state->commit_title_read && len < 1) {
> +               state->commit_title_read = FALSE;
> +               state->after_commit_header = TRUE;
> +       } else if (state->after_commit_header && len < 1) {
> +               state->after_commit_header = FALSE;
> +               state->reading_diff_stat = TRUE;
> +       } else if (state->reading_diff_stat) {
> +               bool ret = diff_common_add_diff_stat(view, data);
> +               if (ret) {
> +                       return TRUE;
> +               } else {
> +                       state->reading_diff_stat = FALSE;
> +               }
> +       }
> +
> +       return pager_common_read(view, data, type);
> +}
> +
> +static bool
> +log_draw(struct view *view, struct line *line, unsigned int lineno)
> +{
> +       char *text = line->data;
> +       enum line_type type = line->type;
> +
This is missing a call to draw_lineno(...)
> +       if (type == LINE_DIFF_STAT) {
> +               diff_common_draw_diff_stat(view, &type, &text);
> +               draw_text(view, type, text);
I had to #include "tig/draw.h" for this to compile.
Show 22 quoted lines
> +               return TRUE;
> +       }
> +
> +       return pager_draw(view, line, lineno);
> +}
> +
>  static struct view_ops log_ops = {
>         "line",
>         argv_env.head,
>         VIEW_ADD_PAGER_REFS | VIEW_OPEN_DIFF | VIEW_SEND_CHILD_ENTER | VIEW_LOG_LIKE | VIEW_REFRESH,
>         sizeof(struct log_state),
>         log_open,
> -       pager_read,
> -       pager_draw,
> +       log_read,
> +       log_draw,
>         log_request,
>         pager_grep,
>         log_select,
> --
> 1.9.1
>
-- 
Jonas Fonseca
Previous: Kumar AppaiahNext: Kumar Appaiah
Message 9 of 11 in “log: colour the diffstat.”
  1. Kumar AppaiahApr 11, 2014
  2. [tig] [PATCH 1/3] diff: Move diff stat addition to a common functionKumar Appaiah, Apr 11, 2014
  3. [tig] [PATCH 2/3] diff: Move diff stat drawing to a common functionKumar Appaiah, Apr 11, 2014
  4. [tig] [PATCH 3/3] log: Colour the diff statKumar Appaiah, Apr 11, 2014
  5. [tig] [PATCHv2 0/3] log: colour the diffstatKumar Appaiah, Apr 13, 2014
  6. [tig] [PATCHv2 1/3] diff: Move diff stat addition to a common functionKumar Appaiah, Apr 13, 2014
  7. [tig] [PATCHv2 2/3] diff: Move diff stat drawing to a common functionKumar Appaiah, Apr 13, 2014
  8. [tig] [PATCHv2 3/3] log: Colour the diff statKumar Appaiah, Apr 13, 2014
  9. Jonas FonsecaApr 17, 2014
  10. Kumar AppaiahApr 17, 2014
  11. Jonas FonsecaApr 17, 2014

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.