diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2017-02-03 03:48:19 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-03 22:18:40 -0800 |
commit | 62a1b732160c363a84be310f801b5dec59196b9c (patch) | |
tree | 4fca423596204c5cff6a46b36a1b528056497bc3 /contrib | |
parent | 69a775963b76824511fe4bdaf949f2e44df4b7a5 (diff) | |
download | git-62a1b732160c363a84be310f801b5dec59196b9c.tar.gz |
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>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/completion/git-completion.bash | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index af5ad52bb1..19f60931b0 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -346,7 +346,11 @@ __git_refs () local list_refs_from=path remote="${1-}" local format refs pfx - if [ -n "$remote" ]; then + if [ -z "$remote" ]; then + if [ -z "$dir" ]; then + return + fi + else if __git_is_configured_remote "$remote"; then # configured remote takes precedence over a # local directory with the same name @@ -360,7 +364,7 @@ __git_refs () fi fi - if [ "$list_refs_from" = path ] && [ -d "$dir" ]; then + if [ "$list_refs_from" = path ]; then case "$cur" in refs|refs/*) format="refname" |