git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] bash-completion: Try bash completions before simple filetype

From
ted@tedpavlic.com <ted@tedpavlic.com>
Date
Jan 14, 2009, 20:02 UTC
Message-ID
<1231963342-24461-2-git-send-email-ted@tedpavlic.com>
In-Reply-To
<1231963342-24461-1-git-send-email-ted@tedpavlic.com>
From: Ted Pavlic <ted@tedpavlic.com>
  When a git completion is not found, a bash shell should try bash-type
  completions first before going to standard filetype completions. This
  patch /adds/ "-o bashdefault" to the completion line. If that option
  is not available, it uses the old method.
  This behavior was inspired by Mercurial's bash completion script.
Signed-off-by: Ted Pavlic <ted@tedpavlic.com>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
---
 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
Previous: ted@tedpavlic.comNext: ted@tedpavlic.com
Message 2 of 6 in “bash-completion: Support running when set -u is enabled”
  1. 1/3 bash-completion: Support running when set -u is enabledted@tedpavlic.com, Jan 14, 2009
  2. 2/3 bash-completion: Try bash completions before simple filetypeted@tedpavlic.com, Jan 14, 2009
  3. 3/3 bash-completion: Added comments to remind about required argumentsted@tedpavlic.com, Jan 14, 2009
  4. Shawn O. PearceJan 15, 2009
  5. Ted PavlicJan 15, 2009
  6. Shawn O. PearceJan 15, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.