From: Stephen Boyd <bebarino@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: [PATCH 2/3] completion: add find_argument_and_value() function
Date: Wed, 6 May 2009 23:18:12 -0700 [thread overview]
Message-ID: <1241677093-29937-1-git-send-email-bebarino@gmail.com> (raw)
In-Reply-To: <1241676906-29783-1-git-send-email-bebarino@gmail.com>
Add a function to get arguments and their associated value. This is used
by the config completion to find config file arguments.
Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---
I'm not sure if this is correct. It works for the case I have, but
others I'm not so sure. Let's just say I'm no bash expert.
contrib/completion/git-completion.bash | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 72a16a1..f179cc8 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -618,6 +618,31 @@ __git_find_subcommand ()
done
}
+# __git_find_argument_and_value requires 1 argument
+__git_find_argument_and_value ()
+{
+ local word nextword argument c=1
+
+ while [ $c -lt $COMP_CWORD ]; do
+ word="${COMP_WORDS[c]}"
+ for argument in $1; do
+ if [ "${argument##--}" = "${word##--}" ]; then
+ nextword=${COMP_WORDS[$((c+1))]}
+ if [ "${nextword#-}" != "$nextword" ]; then
+ nextword=
+ fi
+ echo "$argument $nextword"
+ return
+ fi
+ if [ "${argument/=*/}" = "${word/=*/}" ]; then
+ echo "$word"
+ return
+ fi
+ done
+ c=$((++c))
+ done
+}
+
__git_has_doubledash ()
{
local c=1
--
1.6.3.rc4.29.g8146
next prev parent reply other threads:[~2009-05-07 6:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-07 6:15 [PATCH 1/3] completion: complete config variables for --get/getall/unset/unset-all Stephen Boyd
2009-05-07 6:15 ` [PATCH 2/3] completion: add find_argument_and_value() function Stephen Boyd
2009-05-07 6:18 ` Stephen Boyd [this message]
2009-05-07 6:18 ` [PATCH 3/3] completion: use specified file (if any) when completing config vars Stephen Boyd
2009-05-07 15:12 ` Shawn O. Pearce
2009-05-07 19:55 ` Stephen Boyd
2009-05-09 1:00 ` Stephen Boyd
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=1241677093-29937-1-git-send-email-bebarino@gmail.com \
--to=bebarino@gmail.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).