completion: add file completion tests

The commit fea16b4 (git-completion.bash: add support for path
completion) introduced quite a few changes, without the usual tests.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion: document tilde expansion failure in tests

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion; remove unuseful comments

The only caller, __git_complete_index_file() doesn't specify any limits
to the options for 'git ls-files', neither should this function.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion: use __gitcompadd for __gitcomp_file

Like the rest of the script does; let's not access COMPREPLY directly.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion: refactor diff_index wrappers

At the end of the day what we really need is to find out the files that
have been staged, or modified, because those files are the ones that
make sense to pass as arguments to 'git commit'.

We need diff-index to find those out, since 'git ls-files' doesn't do
that.

But we don't need wrappers and wrappers basically identical to the ones
used for 'git ls-files', when we can pretend it receives a --committable
option that would return what we need.

That way, we can remove a bunch of code without any functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion: refactor __git_complete_index_file()

The calls to __gitcomp_file() are essentially the same, but with
different prefix.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion: avoid compopt -o filenames

If this option causes so much trouble, lets just not use it.

The supposed advantages of specifying the 'filenames' is that 1) a slash
is added at the end, 2) trailing spaces are removed (which doesn't seem
to be true), and 3) special characters are quoted. We can do all those
things by ourselves.

Also, this will allow us to add a space after the completion, just like
it happened before fea16b4 (git-completion.bash: add support for path
completion), and just like the rest of the script does.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion: get rid of __gitcomp_file()

Now that we don't use -o filenames, it's no different from
__gitcomp_nl().

The only reason we might want it is for other shells, like zsh, which
can do more useful things if they know it's a file, like colouring the
output. But that can be done in the zsh completion.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion: add space after completed filename

Just like before fea16b4 (git-completion.bash: add support for path
completion).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion: remove __git_index_file_list_filter()

Refactor the code into the only caller; __git_index_files().

Also, Somehow messing up with the 'path' variable messes up the 'PATH'
variable. So let's not do that.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
completion: zsh: add proper file support

So the files are completed and coloured nicely.

The code would be only a couple of lines if only _multi_parts or
_path_files worked correctly, but alas, they don't.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Merge branch 'fc/bash/files' into fc/zsh/ng