threads / patch / 32348

patchcompletion: complete refs for "git commit -c"

Subject: [PATCH] completion: complete refs for "git commit -c"

## tl;dr

One message between Dec 15, 2012 and Dec 15, 2012. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Jeff King· Dec 15, 2012, 17:46 UTC · lore

The "-c" and "-C" options take an existing commit, so let's complete refs, just as we would for --squash or --fixup.

Signed-off-by: Jeff King <peff@peff.net>
---
I notice that the existing code just handles the "--foo=bar" form of most
options. By checking $prev, we can also handle "--foo bar" form (which
we have to do for short options like "-c"). But it would mean
duplicating all of the existing logic. I don't know if it's worth it or
not, given that nobody has complained.
 contrib/completion/git-completion.bash | 7 +++++++
 1 file changed, 7 insertions(+)
Show changes to contrib/completion/git-completion.bash +7 −0
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0b77eb1..a4c48e1 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -971,6 +971,13 @@ _git_commit ()
 {
 	__git_has_doubledash && return
 
+	case "$prev" in
+	-c|-C)
+		__gitcomp_nl "$(__git_refs)" "" "${cur}"
+		return
+		;;
+	esac
+
 	case "$cur" in
 	--cleanup=*)
 		__gitcomp "default strip verbatim whitespace
-- 
1.8.0.2.4.g59402aa

← back to recent threads