git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Git Mailing List <git@vger.kernel.org>
Subject: Problem completing remotes when .git/remotes exits
Date: Wed, 19 Sep 2012 21:55:28 +0200	[thread overview]
Message-ID: <505A2330.9040800@kdbg.org> (raw)

I have an empty .git/remotes directory. Trying to complete the name of
a remote always reports an error:

git@master:1023> git fetch <TAB>ls: invalid option -- ' '
Try `ls --help' for more information.

I have these:

	alias ls='ls $LS_OPTIONS'
and
	LS_OPTIONS='-N --color=tty -T 0'

I instrumented __git_remotes with set -x, which shows:

git@master:1006> git fetch <TAB>+++ __gitdir
+++ '[' -z '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -d .git ']'
+++ echo .git
++ local i 'IFS=
' d=.git
++ test -d .git/remotes
++ ls '-N --color=tty -T 0' -1 .git/remotes
ls: invalid option -- ' '
Try `ls --help' for more information.
...

Notice that the expansion of $LS_OPTIONS is not split at the blanks,
obviously, because $IFS does not contain a blank at that moment.

The patch below helps, but it looks like a work-around rather than a
solution. Ideas?

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index be800e0..824f5b6 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -369,8 +369,9 @@ __git_refs_remotes ()
 
 __git_remotes ()
 {
-	local i IFS=$'\n' d="$(__gitdir)"
+	local i d="$(__gitdir)"
 	test -d "$d/remotes" && ls -1 "$d/remotes"
+	local IFS=$'\n'
 	for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
 		i="${i#remote.}"
 		echo "${i/.url*/}"

             reply	other threads:[~2012-09-19 19:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 19:55 Johannes Sixt [this message]
2012-09-25 23:00 ` Problem completing remotes when .git/remotes exits SZEDER Gábor
2012-09-25 23:43   ` Junio C Hamano
2012-09-26 11:43     ` SZEDER Gábor
2012-09-26  1:09   ` SZEDER Gábor
2012-09-26  1:26     ` SZEDER Gábor, Johannes Sixt

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=505A2330.9040800@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.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).