git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: "Uwe Kleine-König" <Uwe.Kleine-Koenig@digi.com>,
	"Junio C Hamano" <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] bash completion only provides revs, not paths
Date: Wed, 23 Apr 2008 21:21:29 -0400	[thread overview]
Message-ID: <20080424012129.GU29771@spearce.org> (raw)
In-Reply-To: <20080423055637.GA25446@digi.com>

Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com> wrote:
> > How is this?
>
> I like it and have already applied it.
...
> > Suggested-by: Uwe Kleine-Knig <Uwe.Kleine-Koenig@digi.com>
>
> There is a letter missing in my name.  I wonder why it's always the only
> non-ascii one :-)

Damn.  I'm sorry.  My mailer seems to be dropping it when I
quote you, and I copied your name from the "... wrote:" line
at the top of my message.  I should have copied from the
To: header, where it hasn't been munged.

Fixed commit message below.

--8<--
bash completion: Completely only path names after -- in options

If the user has inserted a -- before the current argument we are
being asked to complete they are most likely trying to force Git into
treating this argument as a path name, and not as a ref.  We should
allow bash to complete it as a path from the local working directory.

Tested-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 contrib/completion/git-completion.bash |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0f5d30c..8d8405e 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -308,7 +308,20 @@ __git_complete_file ()
 
 __git_complete_revlist ()
 {
-	local pfx cur="${COMP_WORDS[COMP_CWORD]}"
+	local c=1 pfx cur
+
+	while [ $c -lt $COMP_CWORD ]; do
+		cur="${COMP_WORDS[c]}"
+		case "$cur" in
+		--)
+			COMPREPLY=()
+			return
+			;;
+		esac
+		c=$((++c))
+	done
+
+	cur="${COMP_WORDS[COMP_CWORD]}"
 	case "$cur" in
 	*...*)
 		pfx="${cur%...*}..."
-- 
1.5.5.1.141.gd55b


-- 
Shawn.

  reply	other threads:[~2008-04-24  1:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-22 11:21 bash completion only provides revs, not paths Uwe Kleine-König
2008-04-23  1:52 ` Shawn O. Pearce
2008-04-23  5:56   ` Uwe Kleine-König
2008-04-24  1:21     ` Shawn O. Pearce [this message]
2008-04-24  5:52       ` [PATCH] " Uwe Kleine-König

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=20080424012129.GU29771@spearce.org \
    --to=spearce@spearce.org \
    --cc=Uwe.Kleine-Koenig@digi.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).