1 From b7c0f1246788d1716c519387d75d7920ef59865a Mon Sep 17 00:00:00 2001
2 From: Jan Palus <jpalus@fastmail.com>
3 Date: Tue, 30 Aug 2022 16:32:24 +0200
4 Subject: [PATCH] cli/ls: sort entries just before listing (after filtering)
6 fixes global entries order being broken after doing `ls -ut`.
7 "upgradable" listing overrides `ls_ents` and hence sort order
8 restoration operates on wrong array. observed broken beavior:
15 should result in (1) and (3) being the same while in fact (2) and (3)
18 - after invoking `ls -ut` package name completion is broken since it
19 uses binary search and therefore relies on correct order
21 also doing `ls -u` might get marginally faster since it no longer needs
22 to sort all available packages, but only those which are upgradable.
25 1 file changed, 3 insertions(+), 3 deletions(-)
27 diff --git a/cli/ls.c b/cli/ls.c
28 index 1808f43..5a94374 100644
31 @@ -368,9 +368,6 @@ static int ls(struct cmdctx *cmdctx)
35 - if ((cmpf = select_cmpf(cmdctx->_flags)))
36 - n_array_sort_ex(ls_ents, cmpf);
38 if (cmdctx->_flags & OPT_LS_UPGRADEABLE) {
41 @@ -386,6 +383,9 @@ static int ls(struct cmdctx *cmdctx)
44 if (n_array_size(ls_ents)) {
45 + if ((cmpf = select_cmpf(cmdctx->_flags)))
46 + n_array_sort_ex(ls_ents, cmpf);
48 rc = do_ls(ls_ents, cmdctx, evrs);