Download raw body.
tog ref -> log -> diff: < > fails to follow branch
Stefan Sperling: > This version fixes the above issues for me. > > diff 3de29130c7ee88da6e0dd01d356a346c78659921 b3796c3623d628cac6cf2e78b080d7bb9ad3e341 Yes, that fixes all problems with < > in the diff view. I think placing some select_displayed_commit() calls in input_log_view() and some further down in log_scroll_*() makes the logic harder to follow. How about this, which puts all select_displayed_commit() calls into input_log_view()? (It also turns select_displayed_commit into a poor name. Not sure what to call it instead, set_selected_commit is already taken.) diff ee75651731664329c921eb8bd51127f13384ed50 /home/naddy/got blob - 71243c7850ea1be2a41ea376e63e2b384bf06df0 file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -1520,12 +1520,29 @@ queue_commits(struct got_commit_graph *graph, struct c return err; } +static void +select_displayed_commit(struct tog_log_view_state *s) +{ + struct commit_queue_entry *entry; + int ncommits = 0; + + entry = s->first_displayed_entry; + while (entry) { + if (ncommits == s->selected) { + s->selected_entry = entry; + break; + } + entry = TAILQ_NEXT(entry, entry); + ncommits++; + } +} + static const struct got_error * draw_commits(struct tog_view *view) { const struct got_error *err = NULL; struct tog_log_view_state *s = &view->state.log; - struct commit_queue_entry *entry; + struct commit_queue_entry *entry = s->selected_entry; const int limit = view->nlines; int width; int ncommits, author_cols = 4; @@ -1535,17 +1552,6 @@ draw_commits(struct tog_view *view) struct tog_color *tc; static const size_t date_display_cols = 12; - entry = s->first_displayed_entry; - ncommits = 0; - while (entry) { - if (ncommits == s->selected) { - s->selected_entry = entry; - break; - } - entry = TAILQ_NEXT(entry, entry); - ncommits++; - } - if (s->selected_entry && !(view->searching && view->search_next_done == 0)) { err = got_object_id_str(&id_str, s->selected_entry->id); @@ -2361,17 +2367,17 @@ input_log_view(struct tog_view **new_view, struct tog_ s->selected--; else log_scroll_up(s, 1); + select_displayed_commit(s); break; case KEY_PPAGE: case CTRL('b'): if (s->first_displayed_entry == NULL) break; - if (TAILQ_FIRST(&s->commits.head) == - s->first_displayed_entry) { + if (TAILQ_FIRST(&s->commits.head) == s->first_displayed_entry) s->selected = 0; - break; - } - log_scroll_up(s, view->nlines - 1); + else + log_scroll_up(s, view->nlines - 1); + select_displayed_commit(s); break; case 'j': case KEY_DOWN: @@ -2380,11 +2386,14 @@ input_log_view(struct tog_view **new_view, struct tog_ if (s->first_displayed_entry == NULL) break; if (s->selected < MIN(view->nlines - 2, - s->commits.ncommits - 1)) { + s->commits.ncommits - 1)) s->selected++; - break; + else { + err = log_scroll_down(view, 1); + if (err) + break; } - err = log_scroll_down(view, 1); + select_displayed_commit(s); break; case KEY_NPAGE: case CTRL('f'): { @@ -2402,7 +2411,7 @@ input_log_view(struct tog_view **new_view, struct tog_ s->selected = MIN(view->nlines - 2, s->commits.ncommits - 1); } - err = NULL; + select_displayed_commit(s); break; } case KEY_RESIZE: @@ -2410,6 +2419,7 @@ input_log_view(struct tog_view **new_view, struct tog_ s->selected = view->nlines - 2; if (s->selected > s->commits.ncommits - 1) s->selected = s->commits.ncommits - 1; + select_displayed_commit(s); if (s->commits.ncommits < view->nlines - 1 && !s->thread_args.log_complete) { s->thread_args.commits_needed += (view->nlines - 1) - @@ -3598,7 +3608,6 @@ input_diff_view(struct tog_view **new_view, struct tog const struct got_error *err = NULL; struct tog_diff_view_state *s = &view->state.diff; struct tog_log_view_state *ls; - struct commit_queue_entry *entry; int i; switch (ch) { @@ -3671,16 +3680,12 @@ input_diff_view(struct tog_view **new_view, struct tog if (s->log_view == NULL) break; ls = &s->log_view->state.log; - entry = TAILQ_PREV(ls->selected_entry, - commit_queue_head, entry); - if (entry == NULL) - break; err = input_log_view(NULL, s->log_view, KEY_UP); if (err) break; - err = set_selected_commit(s, entry); + err = set_selected_commit(s, ls->selected_entry); if (err) break; @@ -3696,21 +3701,11 @@ input_diff_view(struct tog_view **new_view, struct tog break; ls = &s->log_view->state.log; - if (TAILQ_NEXT(ls->selected_entry, entry) == NULL) { - ls->thread_args.commits_needed++; - err = trigger_log_thread(s->log_view, 1); - if (err) - break; - } err = input_log_view(NULL, s->log_view, KEY_DOWN); if (err) break; - entry = TAILQ_NEXT(ls->selected_entry, entry); - if (entry == NULL) - break; - - err = set_selected_commit(s, entry); + err = set_selected_commit(s, ls->selected_entry); if (err) break; -- Christian "naddy" Weisgerber naddy@mips.inka.de
tog ref -> log -> diff: < > fails to follow branch