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

[PATCH] bash: fix long option with argument double completion

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Mar 5, 2008, 19:07 UTC
Message-ID
<1204744069-27217-1-git-send-email-szeder@ira.uka.de>

Pressing TAB right after 'git command --long-option=' results in 'git command --long-option=--long-option=' when the long option requires an argument, but we don't provide completion for its arguments (e.g. commit --author=, apply --exclude=). This patch detects these long options and provides empty completion array for them.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index d890f16..18b4001 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -113,13 +113,21 @@ __gitcomp ()
 	if [ $# -gt 2 ]; then
 		cur="$3"
 	fi
-	for c in $1; do
-		case "$c$4" in
-		--*=*) all="$all$c$4$s" ;;
-		*.)    all="$all$c$4$s" ;;
-		*)     all="$all$c$4 $s" ;;
-		esac
-	done
+	case "$cur" in
+	--*=)
+		COMPREPLY=()
+		return
+		;;
+	*)
+		for c in $1; do
+			case "$c$4" in
+			--*=*) all="$all$c$4$s" ;;
+			*.)    all="$all$c$4$s" ;;
+			*)     all="$all$c$4 $s" ;;
+			esac
+		done
+		;;
+	esac
 	IFS=$s
 	COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
 	return
-- 
1.5.4.3
Message 1 of 1 in “bash: fix long option with argument double completion”
  1. bash: fix long option with argument double completionSZEDER Gábor, Mar 5, 2008

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.