Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15
DORMANTno replies

[PATCH 2/3] Makes the bash completion script try *bash* completions before simple, filetype completions when a git completion is not found. If bash, completions aren't available, the default file completions are used. This, behavior was inspired by Mercurial's bash completion script.

From: Ted Pavlic <hidden>
Date: 2016-06-15 22:45:56

Second in a series of patches that make bash completions more robust to
different interactive shell configurations and editors.


[PATCH 2/3] Makes the bash completion script try *bash* completions 
before simple
  filetype completions when a git completion is not found. If bash
  completions aren't available, the default file completions are used. This
  behavior was inspired by Mercurial's bash completion script.


Signed-off-by: Ted Pavlic <redacted>
---
  contrib/completion/git-completion.bash |    9 ++++++---
  1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 5d1515c..201f9a6 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1766,13 +1766,16 @@ _gitk ()
  	__git_complete_revlist
  }

-complete -o default -o nospace -F _git git
-complete -o default -o nospace -F _gitk gitk
+complete -o bashdefault -o default -o nospace -F _git git 2>/dev/null \
+	|| complete -o default -o nospace -F _git git
+complete -o bashdefault -o default -o nospace -F _gitk gitk 2>/dev/null \
+	|| complete -o default -o nospace -F _gitk gitk

  # The following are necessary only for Cygwin, and only are needed
  # when the user has tab-completed the executable name and consequently
  # included the '.exe' suffix.
  #
  if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
-complete -o default -o nospace -F _git git.exe
+complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
+	|| complete -o default -o nospace -F _git git.exe
  fi
-- 
1.6.1.87.g15624
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help