Skip to content

Commit 3dfe23b

Browse files
szedergitster
authored andcommitted
completion: support completing non-ASCII pathnames
Unless the user has 'core.quotePath=false' somewhere in the configuration, both 'git ls-files' and 'git diff-index' will by default quote any pathnames that contain bytes with values higher than 0x80, and escape those bytes as '\nnn' octal values. This prevents completing paths when the current path component to be completed contains any non-ASCII, most notably UTF-8, characters, because none of the listed quoted paths will match the current word on the command line. Set 'core.quotePath=false' for those 'git ls-files' and 'git diff-index' invocations, so they won't consider bytes higher than 0x80 as "unusual", and won't quote pathnames containing such characters. Note that pathnames containing backslash, double quote, or control characters will still be quoted; a later patch in this series will deal with those. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6bf0ced commit 3dfe23b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

contrib/completion/git-completion.bash

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,12 @@ __gitcomp_file ()
371371
__git_ls_files_helper ()
372372
{
373373
if [ "$2" == "--committable" ]; then
374-
__git -C "$1" diff-index --name-only --relative HEAD
374+
__git -C "$1" -c core.quotePath=false diff-index \
375+
--name-only --relative HEAD
375376
else
376377
# NOTE: $2 is not quoted in order to support multiple options
377-
__git -C "$1" ls-files --exclude-standard $2
378+
__git -C "$1" -c core.quotePath=false ls-files \
379+
--exclude-standard $2
378380
fi
379381
}
380382

t/t9902-completion.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ test_expect_failure 'complete files - quoted characters on cmdline' '
14631463
"New(Dir/New)File.c"
14641464
'
14651465

1466-
test_expect_failure 'complete files - UTF-8 in ls-files output' '
1466+
test_expect_success 'complete files - UTF-8 in ls-files output' '
14671467
test_when_finished "rm -r árvíztűrő" &&
14681468
mkdir árvíztűrő &&
14691469
>"árvíztűrő/Сайн яваарай" &&

0 commit comments

Comments
 (0)