Skip to content

Commit fb72759

Browse files
committed
Teach bash completion about 'git remote update'
Recently the git-remote command grew an update subcommand, which can be used to execute git-fetch across multiple repositories in a single step. These can be configured with the 'remotes.*' configuration options, so we can offer completion for any name that matches and appears to be useful to git-remote update. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent c70680c commit fb72759

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

contrib/completion/git-completion.bash

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,20 +877,32 @@ _git_remote ()
877877
while [ $c -lt $COMP_CWORD ]; do
878878
i="${COMP_WORDS[c]}"
879879
case "$i" in
880-
add|show|prune) command="$i"; break ;;
880+
add|show|prune|update) command="$i"; break ;;
881881
esac
882882
c=$((++c))
883883
done
884884

885885
if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
886-
__gitcomp "add show prune"
886+
__gitcomp "add show prune update"
887887
return
888888
fi
889889

890890
case "$command" in
891891
show|prune)
892892
__gitcomp "$(__git_remotes)"
893893
;;
894+
update)
895+
local i c='' IFS=$'\n'
896+
for i in $(git --git-dir="$(__gitdir)" config --list); do
897+
case "$i" in
898+
remotes.*)
899+
i="${i#remotes.}"
900+
c="$c ${i/=*/}"
901+
;;
902+
esac
903+
done
904+
__gitcomp "$c"
905+
;;
894906
*)
895907
COMPREPLY=()
896908
;;

0 commit comments

Comments
 (0)