From: Todd Zullinger <tmz@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Shawn O. Pearce" <spearce@spearce.org>,
james bardin <jbardin@bu.edu>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] completion: Replace config --list with --get-regexp
Date: Fri, 11 Sep 2009 19:23:45 -0400 [thread overview]
Message-ID: <20090911232344.GH2582@inocybe.localdomain> (raw)
In-Reply-To: <20090911150934.GB977@coredump.intra.peff.net>
James Bardin noted that the completion spewed warnings when no git
config file is present. This is likely a bug to be fixed in git config,
but it's also a good excuse to simplify the completion code by using the
--get-regexp option as Jeff King pointed out.
Signed-off-by: Todd Zullinger <tmz@pobox.com>
---
Jeff King wrote:
> On Fri, Sep 11, 2009 at 07:36:51AM -0700, Shawn O. Pearce wrote:
>
>>> instead of just using "git config --get-regexp 'remote\..*\.url'", which
>>> would be slightly more efficient, and also doesn't have this bug. ;)
>>
>> F'king oversight. You are right, this should be --get-regexp.
>> There isn't a reason here, probably other than "I forgot about
>> --get-regexp when I wrote the original code".
>
> OK. I will leave a bash-completion patch for you (or somebody else
> interested) as I don't use it myself.
Something like this perhaps? Perhaps the commit message could use
adjustment to reference your fix for 'config --list'?
contrib/completion/git-completion.bash | 30 +++++++++---------------------
1 files changed, 9 insertions(+), 21 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index bf688e1..d668fc9 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -318,13 +318,9 @@ __git_remotes ()
echo ${i#$d/remotes/}
done
[ "$ngoff" ] && shopt -u nullglob
- for i in $(git --git-dir="$d" config --list); do
- case "$i" in
- remote.*.url=*)
- i="${i#remote.}"
- echo "${i/.url=*/}"
- ;;
- esac
+ for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
+ i="${i#remote.}"
+ echo "${i/.url*/}"
done
}
@@ -605,13 +601,9 @@ __git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
__git_aliases ()
{
local i IFS=$'\n'
- for i in $(git --git-dir="$(__gitdir)" config --list); do
- case "$i" in
- alias.*)
- i="${i#alias.}"
- echo "${i/=*/}"
- ;;
- esac
+ for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
+ i="${i#alias.}"
+ echo "${i/ */}"
done
}
@@ -1769,13 +1761,9 @@ _git_remote ()
;;
update)
local i c='' IFS=$'\n'
- for i in $(git --git-dir="$(__gitdir)" config --list); do
- case "$i" in
- remotes.*)
- i="${i#remotes.}"
- c="$c ${i/=*/}"
- ;;
- esac
+ for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); do
+ i="${i#remotes.}"
+ c="$c ${i/ */}"
done
__gitcomp "$c"
;;
--
1.6.4.2
--
Todd OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That men do not learn very much from the lessons of history is the
most important of all the lessons of history.
-- Aldous Huxley Collected Essays, 1959
next prev parent reply other threads:[~2009-09-11 23:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-10 15:13 bash_completion outside repo james bardin
2009-09-11 13:11 ` Michael J Gruber
2009-09-11 13:33 ` Todd Zullinger
2009-09-11 14:00 ` james bardin
2009-09-11 14:17 ` Jeff King
2009-09-11 14:36 ` Shawn O. Pearce
2009-09-11 15:09 ` Jeff King
2009-09-11 16:47 ` Jeff King
2009-09-11 20:43 ` Junio C Hamano
2009-09-11 21:12 ` Jeff King
2009-09-11 21:22 ` Junio C Hamano
2009-09-11 21:29 ` Jeff King
2009-09-11 21:57 ` Junio C Hamano
2009-09-11 22:04 ` Junio C Hamano
2009-09-11 22:05 ` Jeff King
2009-09-11 23:23 ` Todd Zullinger [this message]
2009-09-12 18:31 ` [PATCH] completion: Replace config --list with --get-regexp Shawn O. Pearce
2009-09-13 10:51 ` Bert Wesarg
2009-09-13 18:29 ` Todd Zullinger
2009-09-13 20:40 ` Junio C Hamano
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=20090911232344.GH2582@inocybe.localdomain \
--to=tmz@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jbardin@bu.edu \
--cc=peff@peff.net \
--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).