]> git.ipfire.org Git - thirdparty/git.git/commit - t/t9902-completion.sh
t9902-completion: exercise __git_complete_index_file() directly
authorSZEDER Gábor <szeder.dev@gmail.com>
Fri, 18 May 2018 14:17:51 +0000 (16:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 May 2018 00:38:50 +0000 (09:38 +0900)
commit7d314073488ae81b8f5cdecb4d00a78529fa7dc3
tree9cc5f1fef755f82d7320710bbce47f717c04adac
parent8b4c2e0b1c4ff47c07b2c1bbc937bb46e889755e
t9902-completion: exercise __git_complete_index_file() directly

The tests added in 2f271cd9cf (t9902-completion: add tests
demonstrating issues with quoted pathnames, 2018-05-08) and in
2ab6eab4fe (completion: improve handling quoted paths in 'git
ls-files's output, 2018-03-28) have a few shortcomings:

  - All these tests use the 'test_completion' helper function, thus
    they are exercising the whole completion machinery, although they
    are only interested in how git-aware path completion, specifically
    the __git_complete_index_file() function deals with unusual
    characters in pathnames and on the command line.

  - These tests can't satisfactorily test the case of pathnames
    containing spaces, because 'test_completion' gets the words on the
    command line as a single argument and it uses space as word
    separator.

  - Some of the tests are protected by different FUNNYNAMES_* prereqs
    depending on whether they put backslashes and double quotes or
    separator characters (FS, GS, RS, US) in pathnames, although a
    filesystem not allowing one likely doesn't allow the others
    either.

  - One of the tests operates on paths containing '|' and '&'
    characters without being protected by a FUNNYNAMES prereq, but
    some filesystems (notably on Windows) don't allow these characters
    in pathnames, either.

Replace these tests with basically equivalent, more focused tests that
call __git_complete_index_file() directly.  Since this function only
looks at the current word to be completed, i.e. the $cur variable, we
can easily include pathnames containing spaces in the tests, so use
such pathnames instead of pathnames containing '|' and '&'.  Finally,
use only a single FUNNYNAMES prereq for all kinds of special
characters.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t9902-completion.sh