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

[PATCH v2 2/2] completion: complete refs after 'git restore -s'

From
Ákos Uzonyi <uzonyi.akos@gmail.com>
Date
Sep 25, 2020, 21:11 UTC
Message-ID
<20200925211124.1673337-2-uzonyi.akos@gmail.com>
In-Reply-To
<20200925211124.1673337-1-uzonyi.akos@gmail.com>
Currently only the long version (--source=) supports completion.
Add completion support to the short (-s) option too.
Signed-off-by: Ákos Uzonyi <uzonyi.akos@gmail.com>
---
 contrib/completion/git-completion.bash | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3d02bd4de7..0a96ad87e7 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2841,6 +2841,13 @@ _git_reset ()
 
 _git_restore ()
 {
+	case "$prev" in
+	-s)
+		__git_complete_refs
+		return
+		;;
+	esac
+
 	case "$cur" in
 	--conflict=*)
 		__gitcomp "diff3 merge" "" "${cur##--conflict=}"
-- 
2.28.0
Previous: Ákos UzonyiNext: Jacob Keller
Message 2 of 4 in “completion: use "prev" variable instead of introducing "prevword"”
  1. 1/2 completion: use "prev" variable instead of introducing "prevword"Ákos Uzonyi, Sep 25, 2020
  2. 2/2 completion: complete refs after 'git restore -s'Ákos Uzonyi, Sep 25, 2020
  3. Jacob KellerSep 25, 2020
  4. Junio C HamanoSep 26, 2020

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.