Re: [PATCH 2/2] completion: simplify ls-files filter
From: Junio C Hamano <hidden>
Date: 2018-03-18 05:28:39
SZEDER Gábor [off-list ref] writes:
First, neither 'git ls-files' nor 'git diff-index' produce quite the same order as the 'sort' utility does, e.g.: $ touch foo.c foo-zzz.c $ git add foo* $ git diff-index --name-only HEAD foo-zzz.c foo.c $ git diff-index --name-only HEAD |sort foo.c foo-zzz.c
Doesn't this depend on your locale?
$ printf "foo%s\n" .c -zzz.c /c | LC_ALL=C sort
foo-zzz.c
foo.c
foo/c
$ printf "foo%s\n" .c -zzz.c /c | LC_ALL=en_US.UTF-8 sort
foo/c
foo.c
foo-zzz.c
Second, the output of 'git ls-files' is kind of "block-sorted": if you were to invoke it with the options '--cached --modified --others', then it will first list all untracked files in order, then all cached files in order, and finally all modified files in order.
This is a lot more important consideration.
I have a short patch series collecting dust somewhere for a long while, which pulls a couple more tricks to make git-aware path completion faster, but haven't submitted it yet, because it doesn't work quite that well when filenames require quoting. Though, arguably the current version doesn't work quite that well with quoted filenames either, so... Will try to dig up those patches.
Thanks.