completions/git: forward a ./-prefix from the command line

"git add ./" shows only hidden files (if at all). It should show all files
that can be added.
The problem is that candidates come from "git status" which prints clean
relative paths. Let's allow some unclean paths.

This is far from a complete fix but it should work for the common scenario.

Observe that wildcard_complete_internal() actually filters out all non-hidden
files, if the query is `./`.

Closes #9091
This commit is contained in:
Johannes Altmanninger 2022-07-31 00:05:11 +02:00
parent a447cc38a9
commit 88d1317eaa

View file

@ -334,8 +334,12 @@ function __fish_git_files
# If this contains newlines or tabs,
# there is nothing we can do, but that's a general issue with scripted completions.
set file (string trim -c \" -- $file)
# First the relative filename.
printf '%s\t%s\n' "$file" $d
# The relative filename.
if string match -q './*' -- (commandline -ct)
printf './%s\t%s\n' $file $d
else
printf '%s\t%s\n' "$file" $d
end
# Now from repo root.
# Only do this if the filename isn't a simple child,
# or the current token starts with ":"