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

[PATCH v2 1/1] completion: don't complete revs when --no-format-patch

From
Britton Leo Kerin <britton.kerin@gmail.com>
Date
Jan 9, 2024, 01:08 UTC
Message-ID
<a718b5ee-afb0-44bd-a299-3208fac43506@smtp-relay.sendinblue.com>
In-Reply-To
<20240109010830.458775-1-britton.kerin@gmail.com>

In this case the user has specifically said they don't want send-email to run format-patch so revs aren't valid argument completions (and it's likely revs and dirs do have some same names or prefixes as in Documentation/MyFirstContribution.txt 'psuh').

Signed-off-by: Britton Leo Kerin <britton.kerin@gmail.com>
---
 contrib/completion/git-completion.bash | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 185b47d802..c983f3b2ab 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1242,10 +1242,12 @@ __git_find_last_on_cmdline ()
 	while test $# -gt 1; do
 		case "$1" in
 		--show-idx)	show_idx=y ;;
+		--)		shift && break ;;
 		*)		return 1 ;;
 		esac
 		shift
 	done
+	[ $# -eq 1 ] || return 1   # return 1 if we got wrong # of non-opts
 	local wordlist="$1"
 
 	while [ $c -gt "$__git_cmd_idx" ]; do
@@ -2429,7 +2431,9 @@ _git_send_email ()
 		return
 		;;
 	esac
-	__git_complete_revlist
+	if [ "$(__git_find_last_on_cmdline -- "--format-patch --no-format-patch")" != "--no-format-patch" ]; then
+		__git_complete_revlist
+	fi
 }
 
 _git_stage ()
-- 
2.43.0
Previous: Britton Leo KerinNext: Junio C Hamano
Message 5 of 11 in “completion: send-email: don't complete revs when --no-format-patch”
  1. 0/1 completion: send-email: don't complete revs when --no-format-patchBritton Leo Kerin, Jan 8, 2024
  2. Dragan SimicJan 8, 2024
  3. Britton KerinJan 8, 2024
  4. 0/1 completion: don't complete revs when --no-format-patchBritton Leo Kerin, Jan 9, 2024
  5. 1/1 completion: don't complete revs when --no-format-patchBritton Leo Kerin, Jan 9, 2024
  6. Junio C HamanoFeb 7, 2024
  7. Patrick SteinhardtFeb 8, 2024
  8. Britton KerinFeb 14, 2024
  9. Junio C HamanoFeb 21, 2024
  10. Junio C HamanoMar 5, 2024
  11. Junio C HamanoApr 28, 2024

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.