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

[PATCH] completion: fix __git_complete_worktree_paths

From
Rubén Justo <rjusto@gmail.com>
Date
Feb 25, 2024, 08:16 UTC
Message-ID
<a1561e02-40dc-4ac3-ae7a-666db0f810ed@gmail.com>

Use __git to invoke "worktree list" in __git_complete_worktree_paths, to respect any "-C" and "--git-dir" options present on the command line.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
I stumbled upon this in a situation like:
   $ git init /tmp/foo && cd /tmp/foo
   $ git worktree add --orphan foo_wt
   $ git init /tmp/bar && cd /tmp/bar
   $ git worktree add --orphan bar_wt
   $ cd /tmp/foo
   $ git -C /tmp/bar worktree remove <TAB>
   ... expecting /tmp/bar/wt, but ...
   $ git -C /tmp/bar worktree remove /tmp/foo_wt
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 444b3efa63..86e55dc67f 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3571,7 +3571,7 @@ __git_complete_worktree_paths ()
 	# Generate completion reply from worktree list skipping the first
 	# entry: it's the path of the main worktree, which can't be moved,
 	# removed, locked, etc.
-	__gitcomp_nl "$(git worktree list --porcelain |
+	__gitcomp_nl "$(__git worktree list --porcelain |
 		sed -n -e '2,$ s/^worktree //p')"
 }
 
-- 
2.44.0
Next: Rubén Justo
Message 1 of 5 in “completion: fix __git_complete_worktree_paths”
  1. completion: fix __git_complete_worktree_pathsRubén Justo, Feb 25, 2024
  2. completion: fix __git_complete_worktree_pathsRubén Justo, Feb 25, 2024
  3. Patrick SteinhardtFeb 27, 2024
  4. Rubén JustoFeb 27, 2024
  5. completion: fix __git_complete_worktree_pathsRubén Justo, Feb 27, 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.