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

[PATCH 1/1] completion: complete <rev> in `git worktree add <path> <rev>`

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 10, 2018, 15:10 UTC
Message-ID
<830191fbfbf95b9d568ba91ddcdd9860173a476a.1544454643.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.82.git.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

The second non-option argument to `git worktree`'s `add` command is an optional revision. Let's complete it.

Inspired by https://github.com/git-for-windows/git/pull/1681.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 contrib/completion/git-completion.bash | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9e8ec95c3c..4194b4a2e7 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2773,6 +2773,11 @@ _git_worktree ()
 		add,--*)
 			__gitcomp_builtin worktree_add
 			;;
+		add,*)
+			if [ $(__git_count_arguments "worktree") -eq 2 ]; then
+				__git_complete_refs
+			fi
+			;;
 		list,--*)
 			__gitcomp_builtin worktree_list
 			;;
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: SZEDER Gábor
Message 2 of 3 in “worktree: add completion for the rev argument in git worktree add <path> <rev>”
  1. 0/1 worktree: add completion for the rev argument in git worktree add <path> <rev>Johannes Schindelin via GitGitGadget, Dec 10, 2018
  2. 1/1 completion: complete <rev> in `git worktree add <path> <rev>`Johannes Schindelin via GitGitGadget, Dec 10, 2018
  3. SZEDER GáborDec 11, 2018

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.