X-Git-Url: https://git.tld-linux.org/?p=packages%2Fpoldek.git;a=blobdiff_plain;f=sorted-ls-upgradable.patch;fp=sorted-ls-upgradable.patch;h=b97253f1100539c84ea6bb0eadbe1e625671f5b9;hp=0000000000000000000000000000000000000000;hb=6885e3f24ac122b1f5fa08f9349d967235a5a96d;hpb=4681641f45fcd4d3a57510e44ecb002ec390ae22 diff --git a/sorted-ls-upgradable.patch b/sorted-ls-upgradable.patch new file mode 100644 index 0000000..b97253f --- /dev/null +++ b/sorted-ls-upgradable.patch @@ -0,0 +1,53 @@ +From b7c0f1246788d1716c519387d75d7920ef59865a Mon Sep 17 00:00:00 2001 +From: Jan Palus +Date: Tue, 30 Aug 2022 16:32:24 +0200 +Subject: [PATCH] cli/ls: sort entries just before listing (after filtering) + +fixes global entries order being broken after doing `ls -ut`. +"upgradable" listing overrides `ls_ents` and hence sort order +restoration operates on wrong array. observed broken beavior: + +- invoking: + (1) ls -u + (2) ls -ut + (3) ls -u + + should result in (1) and (3) being the same while in fact (2) and (3) + are the same + +- after invoking `ls -ut` package name completion is broken since it + uses binary search and therefore relies on correct order + +also doing `ls -u` might get marginally faster since it no longer needs +to sort all available packages, but only those which are upgradable. +--- + cli/ls.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/cli/ls.c b/cli/ls.c +index 1808f43..5a94374 100644 +--- a/cli/ls.c ++++ b/cli/ls.c +@@ -368,9 +368,6 @@ static int ls(struct cmdctx *cmdctx) + goto l_end; + } + +- if ((cmpf = select_cmpf(cmdctx->_flags))) +- n_array_sort_ex(ls_ents, cmpf); +- + if (cmdctx->_flags & OPT_LS_UPGRADEABLE) { + tn_array *tmp; + +@@ -386,6 +383,9 @@ static int ls(struct cmdctx *cmdctx) + } + + if (n_array_size(ls_ents)) { ++ if ((cmpf = select_cmpf(cmdctx->_flags))) ++ n_array_sort_ex(ls_ents, cmpf); ++ + rc = do_ls(ls_ents, cmdctx, evrs); + + if (cmpf) +-- +2.37.2 +