Re: [pacman-dev] [PATCH 2/2] wip: pacman: rework the UI of -F

2019-02-07 Thread Eli Schwartz
On 2/7/19 11:19 AM, Morgan Adamiec wrote:
> On Thu, 7 Feb 2019 at 03:13, Eli Schwartz  wrote:
>>
>> On 2/6/19 9:22 PM, Morgan Adamiec wrote:
>>> What if we keep-Fo but have it just change the output format? -F and
>>> -Fo would both work on files and paths.

First you say this.

>> What would it mean, though? Perhaps
>>
>> -o, --oneline
>>
>> --
>> Eli Schwartz
>> Bug Wrangler and Trusted User
>>
> 
> Could do but I see no reason why it can't continue to mean "owns"
> 
> Assuming the message is still in the form: opt/ is owned by
> core/filesystem 2018.12-2

Then you say this.

...

Do you not see how "continue to mean 'owns'" and "it just changes the
output format" are logically inconsistent?

If the default is to show you what is "own'ed", and a flag called --owns
reformats the output instead, then the flag is simply a lie.

-- 
Eli Schwartz
Bug Wrangler and Trusted User



signature.asc
Description: OpenPGP digital signature


Re: [pacman-dev] [PATCH 2/2] wip: pacman: rework the UI of -F

2019-02-07 Thread Morgan Adamiec
On Thu, 7 Feb 2019 at 03:13, Eli Schwartz  wrote:
>
> On 2/6/19 9:22 PM, Morgan Adamiec wrote:
> > On Thu, 7 Feb 2019 at 01:31, Allan McRae  wrote:
> >>
> >> On 3/2/19 4:42 am, morganamilo wrote:
> >>> Reworks the UI of -F according to FS#47949
> >>>
> >>> In short -F replaces both -Fs and -Fo.
> >>> --regex/-x has been replaced with --search/-s.
> >>>
> >>> Signed-off-by: morganamilo 
> >>> ---
> >>>
> >>> This patch is WIP. Functional changes made,
> >>> documentation still needs to be changed.
> >>>
> >>> Additionally I think https://bugs.archlinux.org/task/47949#comment143477
> >>> Is a good idea and I will probably be included in v2
> >>>
> >>
> >> I'm OK with the changes (without having done a review of your code...).
> >>  However, I think we need to work on the output.
> >>
> >>
> >> Old:
> >> $ pacman -Fo opt/
> >> opt/ is owned by core/filesystem 2018.12-2
> >> opt/ is owned by extra/bullet 2.88-1
> >> opt/ is owned by extra/postgresql-old-upgrade 10.6-1
> >> opt/ is owned by community/9base 6-6
> >> opt/ is owned by community/aspnet-runtime 2.2.1+102-1
> >> ...
> >>
> >> New:
> >> $ ./src/pacman/pacman -F opt/
> >> core/filesystem 2018.12-2 (base) [installed]
> >> opt/
> >> extra/bullet 2.88-1
> >> opt/
> >> extra/postgresql-old-upgrade 10.6-1
> >> opt/
> >> ...
> >>
> >>
> >> So the new output follows the old -Fs, which was good when the filepath
> >> was different for each match.  But it not great for some situations
> >> now...  That output remains good for the new -Fs (rainbow issues being
> >> ignored!), but a rethink is needed for the new -F operations.
> >>
> >> Allan
> >
> > What if we keep-Fo but have it just change the output format? -F and
> > -Fo would both work on files and paths.
>
> What would it mean, though? Perhaps
>
> -o, --oneline
>
> --
> Eli Schwartz
> Bug Wrangler and Trusted User
>

Could do but I see no reason why it can't continue to mean "owns"

Assuming the message is still in the form: opt/ is owned by
core/filesystem 2018.12-2


Re: [pacman-dev] [PATCH 2/2] wip: pacman: rework the UI of -F

2019-02-06 Thread Eli Schwartz
On 2/6/19 9:22 PM, Morgan Adamiec wrote:
> On Thu, 7 Feb 2019 at 01:31, Allan McRae  wrote:
>>
>> On 3/2/19 4:42 am, morganamilo wrote:
>>> Reworks the UI of -F according to FS#47949
>>>
>>> In short -F replaces both -Fs and -Fo.
>>> --regex/-x has been replaced with --search/-s.
>>>
>>> Signed-off-by: morganamilo 
>>> ---
>>>
>>> This patch is WIP. Functional changes made,
>>> documentation still needs to be changed.
>>>
>>> Additionally I think https://bugs.archlinux.org/task/47949#comment143477
>>> Is a good idea and I will probably be included in v2
>>>
>>
>> I'm OK with the changes (without having done a review of your code...).
>>  However, I think we need to work on the output.
>>
>>
>> Old:
>> $ pacman -Fo opt/
>> opt/ is owned by core/filesystem 2018.12-2
>> opt/ is owned by extra/bullet 2.88-1
>> opt/ is owned by extra/postgresql-old-upgrade 10.6-1
>> opt/ is owned by community/9base 6-6
>> opt/ is owned by community/aspnet-runtime 2.2.1+102-1
>> ...
>>
>> New:
>> $ ./src/pacman/pacman -F opt/
>> core/filesystem 2018.12-2 (base) [installed]
>> opt/
>> extra/bullet 2.88-1
>> opt/
>> extra/postgresql-old-upgrade 10.6-1
>> opt/
>> ...
>>
>>
>> So the new output follows the old -Fs, which was good when the filepath
>> was different for each match.  But it not great for some situations
>> now...  That output remains good for the new -Fs (rainbow issues being
>> ignored!), but a rethink is needed for the new -F operations.
>>
>> Allan
> 
> What if we keep-Fo but have it just change the output format? -F and
> -Fo would both work on files and paths.

What would it mean, though? Perhaps

-o, --oneline

-- 
Eli Schwartz
Bug Wrangler and Trusted User



signature.asc
Description: OpenPGP digital signature


Re: [pacman-dev] [PATCH 2/2] wip: pacman: rework the UI of -F

2019-02-06 Thread Morgan Adamiec
On Thu, 7 Feb 2019 at 01:31, Allan McRae  wrote:
>
> On 3/2/19 4:42 am, morganamilo wrote:
> > Reworks the UI of -F according to FS#47949
> >
> > In short -F replaces both -Fs and -Fo.
> > --regex/-x has been replaced with --search/-s.
> >
> > Signed-off-by: morganamilo 
> > ---
> >
> > This patch is WIP. Functional changes made,
> > documentation still needs to be changed.
> >
> > Additionally I think https://bugs.archlinux.org/task/47949#comment143477
> > Is a good idea and I will probably be included in v2
> >
>
> I'm OK with the changes (without having done a review of your code...).
>  However, I think we need to work on the output.
>
>
> Old:
> $ pacman -Fo opt/
> opt/ is owned by core/filesystem 2018.12-2
> opt/ is owned by extra/bullet 2.88-1
> opt/ is owned by extra/postgresql-old-upgrade 10.6-1
> opt/ is owned by community/9base 6-6
> opt/ is owned by community/aspnet-runtime 2.2.1+102-1
> ...
>
> New:
> $ ./src/pacman/pacman -F opt/
> core/filesystem 2018.12-2 (base) [installed]
> opt/
> extra/bullet 2.88-1
> opt/
> extra/postgresql-old-upgrade 10.6-1
> opt/
> ...
>
>
> So the new output follows the old -Fs, which was good when the filepath
> was different for each match.  But it not great for some situations
> now...  That output remains good for the new -Fs (rainbow issues being
> ignored!), but a rethink is needed for the new -F operations.
>
> Allan

What if we keep-Fo but have it just change the output format? -F and
-Fo would both work on files and paths.


Re: [pacman-dev] [PATCH 2/2] wip: pacman: rework the UI of -F

2019-02-06 Thread Allan McRae
On 3/2/19 4:42 am, morganamilo wrote:
> Reworks the UI of -F according to FS#47949
> 
> In short -F replaces both -Fs and -Fo.
> --regex/-x has been replaced with --search/-s.
> 
> Signed-off-by: morganamilo 
> ---
> 
> This patch is WIP. Functional changes made,
> documentation still needs to be changed.
> 
> Additionally I think https://bugs.archlinux.org/task/47949#comment143477
> Is a good idea and I will probably be included in v2
> 

I'm OK with the changes (without having done a review of your code...).
 However, I think we need to work on the output.


Old:
$ pacman -Fo opt/
opt/ is owned by core/filesystem 2018.12-2
opt/ is owned by extra/bullet 2.88-1
opt/ is owned by extra/postgresql-old-upgrade 10.6-1
opt/ is owned by community/9base 6-6
opt/ is owned by community/aspnet-runtime 2.2.1+102-1
...

New:
$ ./src/pacman/pacman -F opt/
core/filesystem 2018.12-2 (base) [installed]
opt/
extra/bullet 2.88-1
opt/
extra/postgresql-old-upgrade 10.6-1
opt/
...


So the new output follows the old -Fs, which was good when the filepath
was different for each match.  But it not great for some situations
now...  That output remains good for the new -Fs (rainbow issues being
ignored!), but a rethink is needed for the new -F operations.

Allan


[pacman-dev] [PATCH 2/2] wip: pacman: rework the UI of -F

2019-02-02 Thread morganamilo
Reworks the UI of -F according to FS#47949

In short -F replaces both -Fs and -Fo.
--regex/-x has been replaced with --search/-s.

Signed-off-by: morganamilo 
---

This patch is WIP. Functional changes made,
documentation still needs to be changed.

Additionally I think https://bugs.archlinux.org/task/47949#comment143477
Is a good idea and I will probably be included in v2

 src/pacman/conf.h   |   1 -
 src/pacman/files.c  | 119 +++-
 src/pacman/pacman.c |  19 ++-
 3 files changed, 42 insertions(+), 97 deletions(-)

diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index ababf2e0..04bba2dd 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -91,7 +91,6 @@ typedef struct __config_t {
unsigned short op_s_search;
unsigned short op_s_upgrade;
 
-   unsigned short op_f_regex;
unsigned short op_f_machinereadable;
 
unsigned short group;
diff --git a/src/pacman/files.c b/src/pacman/files.c
index 3ebd9b9b..5ec47c54 100644
--- a/src/pacman/files.c
+++ b/src/pacman/files.c
@@ -49,56 +49,6 @@ static void dump_pkg_machinereadable(alpm_db_t *db, 
alpm_pkg_t *pkg)
}
 }
 
-static int files_fileowner(alpm_list_t *syncs, alpm_list_t *targets) {
-   int ret = 0;
-   alpm_list_t *t;
-
-   for(t = targets; t; t = alpm_list_next(t)) {
-   char *filename = t->data;
-   int found = 0;
-   alpm_list_t *s;
-   size_t len = strlen(filename);
-
-   while(len > 1 && filename[0] == '/') {
-   filename++;
-   len--;
-   }
-
-   for(s = syncs; s; s = alpm_list_next(s)) {
-   alpm_list_t *p;
-   alpm_db_t *repo = s->data;
-   alpm_list_t *packages = alpm_db_get_pkgcache(repo);
-
-   for(p = packages; p; p = alpm_list_next(p)) {
-   alpm_pkg_t *pkg = p->data;
-   alpm_filelist_t *files = 
alpm_pkg_get_files(pkg);
-
-   if(alpm_filelist_contains(files, filename)) {
-   if(config->op_f_machinereadable) {
-   
print_line_machinereadable(repo, pkg, filename);
-   } else if(!config->quiet) {
-   const colstr_t *colstr = 
>colstr;
-   printf(_("%s is owned by 
%s%s/%s%s %s%s%s\n"), filename,
-   colstr->repo, 
alpm_db_get_name(repo), colstr->title,
-   
alpm_pkg_get_name(pkg), colstr->version,
-   
alpm_pkg_get_version(pkg), colstr->nocolor);
-   } else {
-   printf("%s/%s\n", 
alpm_db_get_name(repo), alpm_pkg_get_name(pkg));
-   }
-
-   found = 1;
-   }
-   }
-   }
-
-   if(!found) {
-   ret++;
-   }
-   }
-
-   return 0;
-}
-
 static void print_match(alpm_list_t *match, alpm_db_t *repo, alpm_pkg_t *pkg)
 {
alpm_db_t *db_local = alpm_get_localdb(config->handle);
@@ -138,6 +88,15 @@ static int files_search(alpm_list_t *syncs, alpm_list_t 
*targets, int regex) {
alpm_list_t *s;
int found = 0;
regex_t reg;
+   size_t len = strlen(targ);
+   char *exact_file = strchr(targ, '/');
+
+   if(exact_file != NULL) {
+   while(len > 1 && targ[0] == '/') {
+   targ++;
+   len--;
+   }
+   }
 
if(regex) {
if(regcomp(, targ, REG_EXTENDED | REG_NOSUB | 
REG_ICASE | REG_NEWLINE) != 0) {
@@ -153,26 +112,40 @@ static int files_search(alpm_list_t *syncs, alpm_list_t 
*targets, int regex) {
int m;
 
for(p = packages; p; p = alpm_list_next(p)) {
-   size_t f = 0;
-   char* c;
alpm_pkg_t *pkg = p->data;
alpm_filelist_t *files = 
alpm_pkg_get_files(pkg);
alpm_list_t *match = NULL;
 
-   while(f < files->count) {
-   c = strrchr(files->files[f].name, '/');
-   if(c && *(c + 1)) {
-   if(regex) {
-   m = regexec(, (c +