From: Christian Weisgerber Subject: Re: tog: add option for topological sorting in log view To: gameoftrees@openbsd.org Date: Fri, 29 Mar 2024 17:43:43 +0100 tog: add key binding 't' to toggle topological sorting in log view I assume we want a key binding for this? 't'? I'm not sure where to sort it in the man page / help screen. diff 919c86456dcc8803783cc58539fd98c51f2eec98 6af5a5269b7afc25fa8b403736561272c0d12130 commit - 919c86456dcc8803783cc58539fd98c51f2eec98 commit + 6af5a5269b7afc25fa8b403736561272c0d12130 blob - aaebb8ead9f89ebb9cdd5beec214a128914cebe2 blob + 9e57df1ca2fb1be07f2c89743d5e2a378077610c --- tog/tog.1 +++ tog/tog.1 @@ -255,6 +255,11 @@ view and toggle display of merged commits. The .Fl b option determines whether merged commits are displayed initially. +.It Cm t +Toggle display of merged commits in topological order. +The +.Fl t +option determines whether topological sorting is used initially. .It Cm R Open a .Cm ref @@ -332,7 +337,7 @@ work tree, use the repository path associated with thi .It Fl t Display commits in topological order. This option has no effect without the -.Fl b +.Fl b option because a linear history is sorted in topological order by definition. Topological sorting is disabled by default because the present implementation requires that commit history is fully traversed before any output can be shown. blob - 9e08d315873250cfffa04b27d0a49cb92dcbf259 blob + b764e2393f8123ea1ad1e6a4a5c3f0cb3309e83d --- tog/tog.c +++ tog/tog.c @@ -569,6 +569,7 @@ struct tog_help_view_state { KEY_("> .", "Move cursor down one commit"), \ KEY_("Enter", "Open diff view of the selected commit"), \ KEY_("B", "Reload the log view and toggle display of merged commits"), \ + KEY_("t", "Toggle display of merged commits in topological order"), \ KEY_("R", "Open ref view of all repository references"), \ KEY_("T", "Display tree view of the repository from the selected" \ " commit"), \ @@ -4277,6 +4278,11 @@ input_log_view(struct tog_view **new_view, struct tog_ break; err = view_request_new(new_view, view, TOG_VIEW_TREE); break; + case 't': + s->toposort = !s->toposort; + if (!s->log_branches) + break; + /* fallthrough */ case KEY_BACKSPACE: case CTRL('l'): case 'B': @@ -4316,7 +4322,7 @@ input_log_view(struct tog_view **new_view, struct tog_ free(s->start_id); s->start_id = start_id; s->thread_args.start_id = s->start_id; - } else /* 'B' */ + } else if (ch == 'B') s->log_branches = !s->log_branches; if (s->thread_args.pack_fds == NULL) { -- Christian "naddy" Weisgerber naddy@mips.inka.de