completion: do not cache if --git-completion-helper fails
"git <cmd> --git-completion-helper" could fail if the command checks for a repo before parse_options(). If the result is cached, later on when the user moves to a worktree with repo, tab completion will still fail. Avoid this by detecting errors and not cache the completion output.
This commit is contained in:
parent
edc147ffe0
commit
e733d5d898
@ -0,0 +1,51 @@
|
||||
From 69702523afb4de692b415648e53fcfb1b4630f18 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?=
|
||||
<pclouds@gmail.com>
|
||||
Date: Wed, 12 Jun 2019 15:56:06 +0700
|
||||
Subject: [PATCH] completion: do not cache if --git-completion-helper fails
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
"git <cmd> --git-completion-helper" could fail if the command checks for
|
||||
a repo before parse_options(). If the result is cached, later on when
|
||||
the user moves to a worktree with repo, tab completion will still fail.
|
||||
|
||||
Avoid this by detecting errors and not cache the completion output. We
|
||||
can try again and hopefully succeed next time (e.g. when a repo is
|
||||
found).
|
||||
|
||||
Of course if --git-completion-helper fails permanently because of other
|
||||
reasons (*), this will slow down completion. But I don't see any better
|
||||
option to handle that case.
|
||||
|
||||
(*) one of those cases is if __gitcomp_builtin is called on a command
|
||||
that does not support --git-completion-helper. And we do have a
|
||||
generic call
|
||||
|
||||
__git_complete_common "$command"
|
||||
|
||||
but this case is protected with __git_support_parseopt_helper so we're
|
||||
good.
|
||||
|
||||
Reported-by: Felipe Contreras <felipe.contreras@gmail.com>
|
||||
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
|
||||
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
||||
---
|
||||
contrib/completion/git-completion.bash | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
|
||||
index 499e56f83d0a0..00cc695e3d748 100644
|
||||
--- a/contrib/completion/git-completion.bash
|
||||
+++ b/contrib/completion/git-completion.bash
|
||||
@@ -400,7 +400,8 @@ __gitcomp_builtin ()
|
||||
if [ -z "$options" ]; then
|
||||
# leading and trailing spaces are significant to make
|
||||
# option removal work correctly.
|
||||
- options=" $incl $(__git ${cmd/_/ } --git-completion-helper) "
|
||||
+ options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return
|
||||
+
|
||||
for i in $excl; do
|
||||
options="${options/ $i / }"
|
||||
done
|
10
git.spec
10
git.spec
@ -88,7 +88,7 @@
|
||||
|
||||
Name: git
|
||||
Version: 2.22.0
|
||||
Release: 1%{?rcrev}%{?dist}.1
|
||||
Release: 2%{?rcrev}%{?dist}
|
||||
Summary: Fast Version Control System
|
||||
License: GPLv2
|
||||
URL: https://git-scm.com/
|
||||
@ -120,6 +120,11 @@ Source99: print-failed-test-output
|
||||
# https://bugzilla.redhat.com/490602
|
||||
Patch0: git-cvsimport-Ignore-cvsps-2.2b1-Branches-output.patch
|
||||
|
||||
# Don't cache completion results if --git-completion-helper fails
|
||||
# https://public-inbox.org/git/20190612085606.12144-1-pclouds@gmail.com/
|
||||
# https://github.com/gitster/git/commit/69702523a.patch
|
||||
Patch1: 0001-completion-do-not-cache-if-git-completion-helper-fai.patch
|
||||
|
||||
%if %{with docs}
|
||||
# pod2man is needed to build Git.3pm
|
||||
BuildRequires: %{_bindir}/pod2man
|
||||
@ -956,6 +961,9 @@ rmdir --ignore-fail-on-non-empty "$testdir"
|
||||
%{?with_docs:%{_pkgdocdir}/git-svn.html}
|
||||
|
||||
%changelog
|
||||
* Thu Jul 25 2019 Todd Zullinger <tmz@pobox.com> - 2.22.0-2
|
||||
- completion: do not cache if --git-completion-helper fails
|
||||
|
||||
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.22.0-1.1
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user