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

[PATCH] completion: learn to complete `git rebase --onto=`

From
Denton Liu <liu.denton@gmail.com>
Date
Nov 11, 2019, 21:25 UTC
Message-ID
<22e92546ee49d4502fd5a441741a380d62c834c7.1573507362.git.liu.denton@gmail.com>
In-Reply-To
<CACoUkn6D0cUmN1RbcpfERcOJsbGLdwj6oDeF2oRADV+rX2artQ@mail.gmail.com>

In 2b9bd488ae ("completion: teach rebase to use __gitcomp_builtin", 2019-09-12), the completion script learned to complete rebase using __gitcomp_builtin(). However, this resulted in `--onto=` being suggested instead of `--onto `.

Before, when there was a space, we'd start a new word and, as a result, fallback to __git_complete_refs() and `--onto` would be completed this way. However, now we match the `--*` case which does not know how to offer completions for refs.

Teach _git_rebase() to complete refs in the `--onto=` case so that we fix this regression.

Reported-by: Paul Jolly <paul@myitcv.io>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
Thanks for reporting the bug, Paul. I overlooked this case when I made
the commit that you pointed out.
 contrib/completion/git-completion.bash | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 7b1ab46f0b..2b644056af 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2021,6 +2021,10 @@ _git_rebase ()
 		__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
 		return
 		;;
+	--onto=*)
+		__git_complete_refs --cur="${cur##--onto=}"
+		return
+		;;
 	--*)
 		__gitcomp_builtin rebase "" \
 			"$__git_rebase_interactive_inprogress_options"
-- 
2.24.0.300.g722ba42680
Previous: Paul JollyNext: Junio C Hamano
Message 2 of 5 in “Bug in bash completion for git rebase --onto”
  1. Paul JollyNov 11, 2019
  2. completion: learn to complete `git rebase --onto=`Denton Liu, Nov 11, 2019
  3. Junio C HamanoNov 12, 2019
  4. Denton LiuNov 12, 2019
  5. Junio C HamanoNov 13, 2019

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.