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

[PATCH] bash: complete *_HEAD refs if present

From
Ian Ward Comfort <icomfort@stanford.edu>
Date
Mar 17, 2010, 09:20 UTC
Message-ID
<1268817635-7946-1-git-send-email-icomfort@stanford.edu>

We already complete HEAD, of course, and might as well complete the other common refs mentioned in the rev-parse man page: FETCH_HEAD, ORIG_HEAD, and MERGE_HEAD.

Signed-off-by: Ian Ward Comfort <icomfort@stanford.edu>
---
 contrib/completion/git-completion.bash |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index fe93747..733ac39 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -250,7 +250,9 @@ __git_refs ()
 			refs="${cur%/*}"
 			;;
 		*)
-			if [ -e "$dir/HEAD" ]; then echo HEAD; fi
+			for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
+				if [ -e "$dir/$i" ]; then echo $i; fi
+			done
 			format="refname:short"
 			refs="refs/tags refs/heads refs/remotes"
 			;;
-- 
1.7.0.2
Next: Shawn O. Pearce
Message 1 of 2 in “bash: complete *_HEAD refs if present”
  1. bash: complete *_HEAD refs if presentIan Ward Comfort, Mar 17, 2010
  2. Shawn O. PearceMar 17, 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.