public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce•org>
To: Junio C Hamano <junkio@cox•net>
Cc: git@vger•kernel.org
Subject: [PATCH 5/10] Teach bash how to complete git-format-patch.
Date: Mon, 27 Nov 2006 03:41:43 -0500	[thread overview]
Message-ID: <20061127084143.GE19745@spearce.org> (raw)
In-Reply-To: <de7beb117fb963e68e1085b773593be326ffd495.1164616814.git.spearce@spearce.org>

Provide completion for currently known long options supported by
git-format-patch as well as the revision list specification argument,
which is generally either a refname or in the form a..b.

Since _git_log was the only code that knew how to complete a..b, but
we want to start adding option support to _git_log also refactor the
a..b completion logic out into its own function.

Signed-off-by: Shawn O. Pearce <spearce@spearce•org>
---
 contrib/completion/git-completion.bash |   60 +++++++++++++++++++++++--------
 1 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a740d05..729e5a9 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -144,6 +144,26 @@ __git_complete_file ()
 	esac
 }
 
+__git_complete_revlist ()
+{
+	local pfx cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	*...*)
+		pfx="${cur%...*}..."
+		cur="${cur#*...}"
+		COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
+		;;
+	*..*)
+		pfx="${cur%..*}.."
+		cur="${cur#*..}"
+		COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
+		;;
+	*)
+		COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
+		;;
+	esac
+}
+
 __git_commands ()
 {
 	local i IFS=" "$'\n'
@@ -290,6 +310,26 @@ _git_fetch ()
 	esac
 }
 
+_git_format_patch ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--*)
+		COMPREPLY=($(compgen -W "
+			--stdout --attach --thread
+			--output-directory
+			--numbered --start-number
+			--keep-subject
+			--signoff
+			--in-repy-to=
+			--full-index --binary
+			" -- "$cur"))
+		return
+		;;
+	esac
+	__git_complete_revlist
+}
+
 _git_ls_remote ()
 {
 	local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -303,22 +343,7 @@ _git_ls_tree ()
 
 _git_log ()
 {
-	local pfx cur="${COMP_WORDS[COMP_CWORD]}"
-	case "$cur" in
-	*...*)
-		pfx="${cur%...*}..."
-		cur="${cur#*...}"
-		COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
-		;;
-	*..*)
-		pfx="${cur%..*}.."
-		cur="${cur#*..}"
-		COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs)" -- "$cur"))
-		;;
-	*)
-		COMPREPLY=($(compgen -W "$(__git_refs)" -- "$cur"))
-		;;
-	esac
+	__git_complete_revlist
 }
 
 _git_merge ()
@@ -450,6 +475,7 @@ _git ()
 	diff)        _git_diff ;;
 	diff-tree)   _git_diff_tree ;;
 	fetch)       _git_fetch ;;
+	format-patch) _git_format_patch ;;
 	log)         _git_log ;;
 	ls-remote)   _git_ls_remote ;;
 	ls-tree)     _git_ls_tree ;;
@@ -480,6 +506,7 @@ complete -o default            -F _git_checkout git-checkout
 complete -o default -o nospace -F _git_diff git-diff
 complete -o default            -F _git_diff_tree git-diff-tree
 complete -o default -o nospace -F _git_fetch git-fetch
+complete -o default -o nospace -F _git_format_patch git-format-patch
 complete -o default -o nospace -F _git_log git-log
 complete -o default            -F _git_ls_remote git-ls-remote
 complete -o default -o nospace -F _git_ls_tree git-ls-tree
@@ -503,6 +530,7 @@ complete -o default            -F _git_branch git-branch.exe
 complete -o default -o nospace -F _git_cat_file git-cat-file.exe
 complete -o default -o nospace -F _git_diff git-diff.exe
 complete -o default -o nospace -F _git_diff_tree git-diff-tree.exe
+complete -o default -o nospace -F _git_format_patch git-format-patch.exe
 complete -o default -o nospace -F _git_log git-log.exe
 complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
 complete -o default            -F _git_merge_base git-merge-base.exe
-- 
1.4.4.1.ge3fb

  parent reply	other threads:[~2006-11-27  8:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <de7beb117fb963e68e1085b773593be326ffd495.1164616814.git.spearce@spearce.org>
2006-11-27  8:41 ` [PATCH 2/10] Hide plumbing/transport commands from bash completion Shawn O. Pearce
2006-11-27  8:41 ` [PATCH 3/10] Teach bash how to complete options for git-name-rev Shawn O. Pearce
2006-11-27  8:41 ` [PATCH 4/10] Add current branch in PS1 support to git-completion.bash Shawn O. Pearce
2006-11-27 15:31   ` Sean
     [not found]   ` <20061127103111.4835bffc.seanlkml@sympatico.ca>
2006-11-27 16:51     ` Shawn Pearce
2006-11-27 17:26       ` Sean
     [not found]       ` <20061127122653.3e801d7a.seanlkml@sympatico.ca>
2006-11-27 17:31         ` Shawn Pearce
2006-11-27 17:45           ` Sean
2006-11-27  8:41 ` Shawn O. Pearce [this message]
2006-11-27  8:50   ` [PATCH 5/10] Teach bash how to complete git-format-patch Jakub Narebski
2006-11-27  8:41 ` [PATCH 6/10] Teach bash how to complete git-cherry-pick Shawn O. Pearce
2006-11-27  8:42 ` [PATCH 7/10] Teach bash how to complete git-rebase Shawn O. Pearce
2006-11-27  8:42 ` [PATCH 8/10] Teach bash about git log/show/whatchanged options Shawn O. Pearce
2006-11-27  8:42 ` [PATCH 9/10] Allow completion of --committer and --author arguments to git log Shawn O. Pearce
2006-11-27 10:28   ` Nicolas Vilz
2006-11-27 16:46     ` Shawn Pearce
2006-11-27 20:20   ` Junio C Hamano
2006-11-27 20:49     ` Shawn Pearce
2006-11-27  8:42 ` [PATCH 10/10] Support bash completion of refs/remote Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061127084143.GE19745@spearce.org \
    --to=spearce@spearce$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    --cc=junkio@cox$(echo .)net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox