Bash auto completion supplies a function __git_remotes which
lists the git remotes of a repository by reading the
.git/remotes directory.  As of git 1.7.6 this is handled
natively by the `git remote` command.  This function is
now deprecated.

Signed-off-by: Matt Korostoff <mkorost...@gmail.com>
---

*****

Great point Gabor! I would hesitate a little about removing the function 
entirely, because users may have external scripts that rely on this function,
but certainly for our internal purposes the __git_remotes shell function can be
replaced with the native.  Here's a short screen cast of the included patch 
working on my local http://i.imgur.com/6ZSMXCO.gif

*****

 contrib/completion/git-completion.bash |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 2fece98..8b41871 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -409,14 +409,14 @@ __git_refs_remotes ()
        done
 }
 
+# Deprecated wrapper function around git remote.  Supplied for legacy purposes,
+# to avoid breaking any external scripts which rely on this function.
+# Originally this function was used to programmatically generate a list of git
+# remotes by reading the .git/remotes directory, but as of git 1.7.6 that is
+# natively handled by the git remote command
 __git_remotes ()
 {
-       local i IFS=$'\n' d="$(__gitdir)"
-       test -d "$d/remotes" && ls -1 "$d/remotes"
-       for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 
2>/dev/null); do
-               i="${i#remote.}"
-               echo "${i/.url*/}"
-       done
+       git remote
 }
 
 __git_list_merge_strategies ()
@@ -558,7 +558,7 @@ __git_complete_remote_or_refspec ()
                ((c++))
        done
        if [ -z "$remote" ]; then
-               __gitcomp_nl "$(__git_remotes)"
+               __gitcomp_nl "$(git remote)"
                return
        fi
        if [ $no_complete_refspec = 1 ]; then
@@ -927,7 +927,7 @@ _git_archive ()
                return
                ;;
        --remote=*)
-               __gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"
+               __gitcomp_nl "$(git remote)" "" "${cur##--remote=}"
                return
                ;;
        --*)
@@ -1397,7 +1397,7 @@ _git_ls_files ()
 
 _git_ls_remote ()
 {
-       __gitcomp_nl "$(__git_remotes)"
+       __gitcomp_nl "$(git remote)"
 }
 
 _git_ls_tree ()
@@ -1639,7 +1639,7 @@ _git_push ()
 {
        case "$prev" in
        --repo)
-               __gitcomp_nl "$(__git_remotes)"
+               __gitcomp_nl "$(git remote)"
                return
                ;;
        --recurse-submodules)
@@ -1649,7 +1649,7 @@ _git_push ()
        esac
        case "$cur" in
        --repo=*)
-               __gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"
+               __gitcomp_nl "$(git remote)" "" "${cur##--repo=}"
                return
                ;;
        --recurse-submodules=*)
@@ -1797,7 +1797,7 @@ _git_config ()
 {
        case "$prev" in
        branch.*.remote|branch.*.pushremote)
-               __gitcomp_nl "$(__git_remotes)"
+               __gitcomp_nl "$(git remote)"
                return
                ;;
        branch.*.merge)
@@ -1809,7 +1809,7 @@ _git_config ()
                return
                ;;
        remote.pushdefault)
-               __gitcomp_nl "$(__git_remotes)"
+               __gitcomp_nl "$(git remote)"
                return
                ;;
        remote.*.fetch)
@@ -1944,7 +1944,7 @@ _git_config ()
                ;;
        remote.*)
                local pfx="${cur%.*}." cur_="${cur#*.}"
-               __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
+               __gitcomp_nl "$(git remote)" "$pfx" "$cur_" "."
                __gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
                return
                ;;
@@ -2250,7 +2250,7 @@ _git_remote ()
 
        case "$subcommand" in
        rename|remove|set-url|show|prune)
-               __gitcomp_nl "$(__git_remotes)"
+               __gitcomp_nl "$(git remote)"
                ;;
        set-head|set-branches)
                __git_complete_remote_or_refspec
-- 
1.7.10.2 (Apple Git-33)

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to