Subject: bug#60264: 29.0.60; Strange file completion candidates for shadowed file paths

From: Stefan Monnier <[email-masked]>
Date: Fri, 23 Dec 2022 09:08:37 -0500

>> 1. Start emacs -Q
>> 2. C-x C-f
>> 3. Delete the entire minibuffer input
>> 4. Enter /etc//s
>> 5. Press ?
>> 
>> You will see candidates like etc//sbin/. The candidates can get even
>> stranger. If you enter /etc//etc//etc/s then you will get candidates
>> like etc//etc//etc//sbin/. I can reproduce this bug on 27 and 29. I
>> haven't tried 28, but the issue should exist there too.
>
> I don't think it's a bug (look at what the minibuffer shows in those
> cases), perhaps just a minor aesthetic thing, but I'm adding Stefan in
> case he has comments.

He's right, that's a bug.  *Completions* normally only shows the list of
matching files in the final directory, so complete filenames.  It's even
more true here where the "excess" is not even really part of the file
name since it'll be stripped away by `substitute-in-file-name`.

E.g. if you replace "/etc//s" with "~//s" in the example, we show the
correct list.

        Stefan