{"thread":{"id":"43693","subject":"[PATCH 3/6] Bash completion support for remotes in .git/config.","startedAt":"2006-11-05T11:21:03Z","lastAt":"2006-11-05T11:21:03Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"296753","messageId":"20061105112103.GC20495@spearce.org","threadId":"43693","inReplyTo":null,"subject":"[PATCH 3/6] Bash completion support for remotes in .git/config.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-11-05T11:21:03Z","receivedAt":"2006-11-05T11:21:03Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Now that Git natively supports remote specifications within the\nconfig file such as:\n\n\t[remote \"origin\"]\n\t\turl = ...\n\nwe should provide bash completion support \"out of the box\" for\nthese remotes, just like we do for the .git/remotes directory.\n\nAlso cleaned up the __git_aliases expansion to use the same form\nof querying and filtering repo-config as this saves two fork/execs\nin the middle of a user prompted completion.  Finally also forced\nthe variable 'word' to be local within __git_aliased_command.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n contrib/completion/git-completion.bash |   26 +++++++++++++++++++++-----\n 1 files changed, 21 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 926638d..5f1be46 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -59,12 +59,21 @@ __git_refs2 ()\n \n __git_remotes ()\n {\n-\tlocal i REVERTGLOB=$(shopt -p nullglob)\n+\tlocal i ngoff IFS=$'\\n'\n+\tshopt -q nullglob || ngoff=1\n \tshopt -s nullglob\n \tfor i in .git/remotes/*; do\n \t\techo ${i#.git/remotes/}\n \tdone\n-\t$REVERTGLOB\n+\t[ \"$ngoff\" ] && shopt -u nullglob\n+\tfor i in $(git repo-config --list); do\n+\t\tcase \"$i\" in\n+\t\tremote.*.url=*)\n+\t\t\ti=\"${i#remote.}\"\n+\t\t\techo \"${i/.url=*/}\"\n+\t\t\t;;\n+\t\tesac\n+\tdone\n }\n \n __git_complete_file ()\n@@ -103,13 +112,20 @@ __git_complete_file ()\n \n __git_aliases ()\n {\n-\tgit repo-config --list | grep '^alias\\.' \\\n-\t\t| sed -e 's/^alias\\.//' -e 's/=.*$//'\n+\tlocal i IFS=$'\\n'\n+\tfor i in $(git repo-config --list); do\n+\t\tcase \"$i\" in\n+\t\talias.*)\n+\t\t\ti=\"${i#alias.}\"\n+\t\t\techo \"${i/=*/}\"\n+\t\t\t;;\n+\t\tesac\n+\tdone\n }\n \n __git_aliased_command ()\n {\n-\tlocal cmdline=$(git repo-config alias.$1)\n+\tlocal word cmdline=$(git repo-config --get \"alias.$1\")\n \tfor word in $cmdline; do\n \t\tif [ \"${word##-*}\" ]; then\n \t\t\techo $word\n-- \n1.4.3.3.g9621\n"}]}