completion: don't list 'HEAD' when trying refs completion outside of a repo

When refs completion is attempted while not in a git repository, the
completion script offers 'HEAD' erroneously.

Check early in __git_refs() that there is either a repository or a
remote to work on, and return early if neither is given.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
SZEDER Gábor
2017-02-03 03:48:19 +01:00
committed by Junio C Hamano
parent 69a775963b
commit 62a1b73216
2 changed files with 7 additions and 3 deletions

View File

@ -599,7 +599,7 @@ test_expect_success '__git_refs - non-existing URL remote - full refs' '
test_must_be_empty "$actual"
'
test_expect_failure '__git_refs - not in a git repository' '
test_expect_success '__git_refs - not in a git repository' '
(
GIT_CEILING_DIRECTORIES="$ROOT" &&
export GIT_CEILING_DIRECTORIES &&