]>
Commit | Line | Data |
---|---|---|
c447c41d JP |
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) | |
5 | ||
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: | |
9 | ||
10 | - invoking: | |
11 | (1) ls -u | |
12 | (2) ls -ut | |
13 | (3) ls -u | |
14 | ||
15 | should result in (1) and (3) being the same while in fact (2) and (3) | |
16 | are the same | |
17 | ||
18 | - after invoking `ls -ut` package name completion is broken since it | |
19 | uses binary search and therefore relies on correct order | |
20 | ||
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. | |
23 | --- | |
24 | cli/ls.c | 6 +++--- | |
25 | 1 file changed, 3 insertions(+), 3 deletions(-) | |
26 | ||
27 | diff --git a/cli/ls.c b/cli/ls.c | |
28 | index 1808f43..5a94374 100644 | |
29 | --- a/cli/ls.c | |
30 | +++ b/cli/ls.c | |
31 | @@ -368,9 +368,6 @@ static int ls(struct cmdctx *cmdctx) | |
32 | goto l_end; | |
33 | } | |
34 | ||
35 | - if ((cmpf = select_cmpf(cmdctx->_flags))) | |
36 | - n_array_sort_ex(ls_ents, cmpf); | |
37 | - | |
38 | if (cmdctx->_flags & OPT_LS_UPGRADEABLE) { | |
39 | tn_array *tmp; | |
40 | ||
41 | @@ -386,6 +383,9 @@ static int ls(struct cmdctx *cmdctx) | |
42 | } | |
43 | ||
44 | if (n_array_size(ls_ents)) { | |
45 | + if ((cmpf = select_cmpf(cmdctx->_flags))) | |
46 | + n_array_sort_ex(ls_ents, cmpf); | |
47 | + | |
48 | rc = do_ls(ls_ents, cmdctx, evrs); | |
49 | ||
50 | if (cmpf) | |
51 | -- | |
52 | 2.37.2 | |
53 |