# [PATCH] git-completion: offer remotes for 'git remote update'

4 messages from 2011-09-25 to 2011-09-28. Participants: Auke Schrijnen, Junio C Hamano.
Thread: https://gitlist.dev/t/28491

## Auke Schrijnen, 2011-09-25 12:06

Subject: [PATCH] git-completion: offer remotes for 'git remote update'
Message-ID: <347b845858abcc62551d83df324e5c10@schrijnen.nl>
URL: https://gitlist.dev/e/347b845858abcc62551d83df324e5c10%40schrijnen.nl

```
Completion for 'git remote update' only offers configured remote
groups.

Add all remotes to the completion.

Signed-off-by: Auke Schrijnen <auke@schrijnen.nl>
---
  contrib/completion/git-completion.bash |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 8648a36..ad2175c 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2293,7 +2293,7 @@ _git_remote ()
  		__gitcomp "$(__git_remotes)"
  		;;
  	update)
-		local i c='' IFS=$'\n'
+		local i c="$(__git_remotes)" IFS=$'\n'
  		for i in $(git --git-dir="$(__gitdir)" config --get-regexp 
"remotes\..*" 2>/dev/null); do
  			i="${i#remotes.}"
  			c="$c ${i/ */}"
-- 
1.7.6.1

```

## Junio C Hamano, 2011-09-28 00:47

Subject: Re: [PATCH] git-completion: offer remotes for 'git remote update'
Message-ID: <7v8vp9trvu.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v8vp9trvu.fsf%40alter.siamese.dyndns.org
In-Reply-To: <347b845858abcc62551d83df324e5c10@schrijnen.nl>

```
Auke Schrijnen <auke@schrijnen.nl> writes:

> Completion for 'git remote update' only offers configured remote
> groups.

I have this suspicion that it might even be a feature. I am a bad person
to make the judgement, as I do not use the "grouping" feature at all.

If you throw in individual remotes that are not grouped in the mix, the
users of "git remote update" auto-completion, who have been happily
relying on seeing only the configured groups, suddenly will start seeing
many individual repositories offered, cluttering the available choices.
Besides, if you want to fetch from a single source, why not use "git
fetch" directly?

Back when "git fetch" didn't allow fetching from multiple repositories in
one go, "remote update" was written as a wrapper for the explicit purpose
of fetching from more than one remote by defining remote groups. Since
late 2009, "git fetch" can update from multiple remotes itself, and I
suspect "git remote update" outlived its usefulness in some sense, but
that is a tangent.

```

## Auke Schrijnen, 2011-09-28 08:52

Subject: Re: [PATCH] git-completion: offer remotes for 'git remote update'
Message-ID: <8afccd5cb106493a55415bec66328063@schrijnen.nl>
URL: https://gitlist.dev/e/8afccd5cb106493a55415bec66328063%40schrijnen.nl
In-Reply-To: <7v8vp9trvu.fsf@alter.siamese.dyndns.org>

```
On Tue, 27 Sep 2011 17:47:17 -0700, Junio C Hamano wrote:
> Auke Schrijnen <auke@schrijnen.nl> writes:
>
>> Completion for 'git remote update' only offers configured remote
>> groups.
>
> I have this suspicion that it might even be a feature. I am a bad 
> person
> to make the judgement, as I do not use the "grouping" feature at all.
>
> If you throw in individual remotes that are not grouped in the mix, 
> the
> users of "git remote update" auto-completion, who have been happily
> relying on seeing only the configured groups, suddenly will start 
> seeing
> many individual repositories offered, cluttering the available 
> choices.
> Besides, if you want to fetch from a single source, why not use "git
> fetch" directly?
>
> Back when "git fetch" didn't allow fetching from multiple 
> repositories in
> one go, "remote update" was written as a wrapper for the explicit 
> purpose
> of fetching from more than one remote by defining remote groups. 
> Since
> late 2009, "git fetch" can update from multiple remotes itself, and I
> suspect "git remote update" outlived its usefulness in some sense, 
> but
> that is a tangent.

I see your point and obviously i'm also not using the grouping feature. 
I could just use git fetch but i'm so used to type 'git remote 
update'... So i'll cook another patch.

Auke

```

## Auke Schrijnen, 2011-09-28 08:54

Subject: [PATCH] git-completion: offer remotes for 'git remote update'
Message-ID: <1fe2227149aa8b1024dd0f220e32af20@schrijnen.nl>
URL: https://gitlist.dev/e/1fe2227149aa8b1024dd0f220e32af20%40schrijnen.nl
In-Reply-To: <7v8vp9trvu.fsf@alter.siamese.dyndns.org>

```
Completion for 'git remote update' only offers configured remote
groups. This is fine if one uses remote groups but there is no
completion without those groups.

Add all remotes to the completion when no configured groups are found.

Signed-off-by: Auke Schrijnen <auke@schrijnen.nl>
---
  contrib/completion/git-completion.bash |    6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 8648a36..12058bf 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2298,7 +2298,11 @@ _git_remote ()
  			i="${i#remotes.}"
  			c="$c ${i/ */}"
  		done
-		__gitcomp "$c"
+		if [ -z "$c" ]; then
+			__gitcomp "$(__git_remotes)"
+		else
+			__gitcomp "$c"
+		fi
  		;;
  	*)
  		COMPREPLY=()
-- 
1.7.6.1

```
