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

[PATCH] bash completion: add basic support for git-reflog

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Nov 22, 2010, 17:09 UTC
Message-ID
<1290445749-4884-1-git-send-email-rctay89@gmail.com>
In-Reply-To
<AANLkTinJPQF-khzViED+ROyojEr9nHrcgwKQWsDugD7Y@mail.gmail.com>

"Promote" the reflog command out of plumbing, so that we now run completion for it. After all, it's listed under porcelain (ancillary), and we do run completion for those commands.

Add basic completion for the three subcommands - show, expire, delete. Try completing refs for these too.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
Changed from v1: 
 - picked up Gábor's suggestion on using __git_find_on_cmdline()
   to correctly handle situations where subcommands are used with dashed
   options.
 - don't "hide" reflog anymore - run completion for it too.

Gábor: hmm, it really seems that reflog is treated as plumbing - no completion is done for it. Even get-tar-commit-id (I've never used this before) is treated better than reflog. Shall do something about it!

 contrib/completion/git-completion.bash |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index f710469..6732b1d 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -735,7 +735,6 @@ __git_list_porcelain_commands ()
 		quiltimport)      : import;;
 		read-tree)        : plumbing;;
 		receive-pack)     : plumbing;;
-		reflog)           : plumbing;;
 		remote-*)         : transport;;
 		repo-config)      : deprecated;;
 		rerere)           : plumbing;;
@@ -1632,6 +1631,18 @@ _git_rebase ()
 	__gitcomp "$(__git_refs)"
 }
 
+_git_reflog ()
+{
+	local subcommands="show delete expire"
+	local subcommand="$(__git_find_on_cmdline "$subcommands")"
+
+	if [ -z "$subcommand" ]; then
+		__gitcomp "$subcommands"
+	else
+		__gitcomp "$(__git_refs)"
+	fi
+}
+
 __git_send_email_confirm_options="always never auto cc compose"
 __git_send_email_suppresscc_options="author self cc bodycc sob cccmd body all"
 
-- 
1.7.3.2.493.g2b058
Previous: Tay Ray ChuanNext: Jonathan Nieder
Message 4 of 5 in “bash completion: add basic support for git-reflog”
  1. bash completion: add basic support for git-reflogTay Ray Chuan, Nov 20, 2010
  2. SZEDER GáborNov 22, 2010
  3. Tay Ray ChuanNov 22, 2010
  4. bash completion: add basic support for git-reflogTay Ray Chuan, Nov 22, 2010
  5. Jonathan NiederNov 22, 2010

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.