From: Mark Jamsek Subject: Re: tog: base commit marker in limit view To: Mikhail Cc: gameoftrees@openbsd.org Date: Sat, 12 Aug 2023 18:14:08 +1000 Mikhail wrote: > In limit view (&) tog shows base commit marker on the first commit every > time. > > Inlined patch removes the marker if we are in limit view. > > diff /home/misha/work/got > commit - 123cba5ad6fe36893f2019bb0a806db3f3139dde > path + /home/misha/work/got > blob - c4839d1c9023a068753142f189620d39826b0968 > file + tog/tog.c > --- tog/tog.c > +++ tog/tog.c > @@ -2498,7 +2498,7 @@ draw_commit(struct tog_view *view, struct commit_queue > while (col < avail && author_width < author_display_cols + 2) { > if (tog_base_commit.marker != GOT_WORKTREE_STATE_UNKNOWN && > author_width == marker_column && > - entry->idx == tog_base_commit.idx) { > + entry->idx == tog_base_commit.idx && !s->limit_view) { > tc = get_color(&s->colors, TOG_COLOR_COMMIT); > if (tc) > wattr_on(view->window, Thanks, Mikhail! I completely forgot about the limit option. This is another ideal test case too, which I'll add to the list :) While the proposed patch is indeed better than the current behaviour, I don't think it is the best way to do this because it will fail to show the marker if the limit view does contain the base commit. For example, in a work tree with the current HEAD, '&log' will keep the base commit in view but the marker will not be drawn. The below patch improves on this so that if the base commit is listed in the limit view, it will be marked. diffstat cb9ee4449db34bd1b965700eb1c457356d056b4d 411983e6da8306e29542c10edf1c007693985bd5 M tog/tog.c | 22+ 10- 1 file changed, 22 insertions(+), 10 deletions(-) diff cb9ee4449db34bd1b965700eb1c457356d056b4d 411983e6da8306e29542c10edf1c007693985bd5 commit - cb9ee4449db34bd1b965700eb1c457356d056b4d commit + 411983e6da8306e29542c10edf1c007693985bd5 blob - d0f674078d9fb63ad070889a2c85507fd302daf3 blob + d7555b4e32e0428476d82933549bb8f17cd73603 --- tog/tog.c +++ tog/tog.c @@ -2404,6 +2404,20 @@ static const struct got_error * col_tab_align, 0); } +static void +draw_base_commit_marker(struct tog_view *view) +{ + struct tog_log_view_state *s = &view->state.log; + struct tog_color *tc; + + tc = get_color(&s->colors, TOG_COLOR_COMMIT); + if (tc != NULL) + wattr_on(view->window, COLOR_PAIR(tc->colorpair), NULL); + waddch(view->window, tog_base_commit.marker); + if (tc != NULL) + wattr_off(view->window, COLOR_PAIR(tc->colorpair), NULL); +} + static const struct got_error * draw_commit(struct tog_view *view, struct commit_queue_entry *entry, const size_t date_display_cols, int author_display_cols) @@ -2498,16 +2512,14 @@ draw_commit(struct tog_view *view, struct commit_queue while (col < avail && author_width < author_display_cols + 2) { if (tog_base_commit.marker != GOT_WORKTREE_STATE_UNKNOWN && author_width == marker_column && - entry->idx == tog_base_commit.idx) { - tc = get_color(&s->colors, TOG_COLOR_COMMIT); - if (tc) - wattr_on(view->window, - COLOR_PAIR(tc->colorpair), NULL); - waddch(view->window, tog_base_commit.marker); - if (tc) - wattr_off(view->window, - COLOR_PAIR(tc->colorpair), NULL); - } else + entry->idx == tog_base_commit.idx && !s->limit_view) + draw_base_commit_marker(view); + else if (s->limit_view && author_width == marker_column && + tog_base_commit.marker != GOT_WORKTREE_STATE_UNKNOWN && + tog_base_commit.id != NULL && + got_object_id_cmp(id, tog_base_commit.id) == 0) + draw_base_commit_marker(view); + else waddch(view->window, ' '); col++; author_width++; -- Mark Jamsek GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68