jj icon indicating copy to clipboard operation
jj copied to clipboard

FR: Option to sort listed branches based on last commit date

Open gpanders opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

Git has the ability to sort the output of git branch based on last commit date with git branch --sort=-committerdate (or git config branch.sort -committerdate). I find this extremely useful since the branches that I am mostly frequently switching between are the ones that have been active recently.

jj lists all branches alphabetically by default, but it'd be great to have the ability to list them based on the last commit date as well.

Describe the solution you'd like

Simple option would be to add a -s/--sort flag to jj branch list. As a first implementation, this could support only name and committerdate (I don't have strong opinions on what term to use here, for now just copying from Git). Like Git, prefixing the sort key with - sorts in descending order.

Describe alternatives you've considered

This could maybe also be done with a template for the entire output of jj branch list? I don't know if the templating engine could support sorting though.

Additional context N/A

gpanders avatar Jun 05 '24 01:06 gpanders