commit:     fabda847f4690cac36728ec8372f4fe82a8ba9f1
Author:     Tim Harder <radhermit <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 20 22:27:43 2014 +0000
Commit:     Tim Harder <radhermit <AT> gentoo <DOT> org>
CommitDate: Sat Dec 20 22:27:43 2014 +0000
URL:        
http://sources.gentoo.org/gitweb/?p=proj/zsh-completion.git;a=commit;h=fabda847

_gentoo_repos: drop duplicated output functionality

Also, calling _gentoo_repos with no arguments returns all configured
repos instead of just the main repo. To get the path for the main repo
use `_gentoo_repos -m`.

---
 src/_gentoo_packages | 10 +++++-----
 src/_gentoo_repos    | 44 ++++++++++++++++++++++----------------------
 src/_portage_utils   |  2 +-
 3 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/_gentoo_packages b/src/_gentoo_packages
index fa782e4..f15487c 100644
--- a/src/_gentoo_packages
+++ b/src/_gentoo_packages
@@ -89,7 +89,7 @@ _gentoo_packages_update_useflag(){
   local flags trees
 
   flags=()
-  trees=($(_gentoo_repos) $(_gentoo_repos -o))
+  trees=($(_gentoo_repos))
 
   for PORTDIR in ${trees[@]}; do
      [[ -r ${PORTDIR}/profiles/use.desc ]] &&
@@ -114,7 +114,7 @@ _gentoo_packages_update_active_useflag(){
 _gentoo_packages_update_category(){
   local trees category
 
-  trees=($(_gentoo_repos) $(_gentoo_repos -o))
+  trees=($(_gentoo_repos))
   category=( $trees/*-*(/:t) )
   _wanted cat_packages expl 'category' compadd "$@" $category
 }
@@ -144,7 +144,7 @@ _gentoo_packages_update_installed_versions(){
 _gentoo_packages_update_available_pkgnames_only(){
   local trees packages
 
-  trees=($(_gentoo_repos) $(_gentoo_repos -o))
+  trees=($(_gentoo_repos))
 
   packages=($trees/*-*/*(:t))
   _wanted packages expl 'package' compadd - "${(@)packages}"
@@ -153,7 +153,7 @@ _gentoo_packages_update_available_pkgnames_only(){
 _gentoo_packages_update_available(){
   local trees category packages pkg expl
 
-  trees=($(_gentoo_repos) $(_gentoo_repos -o))
+  trees=($(_gentoo_repos))
   category=($trees/*-*(/:t))
 
   packages=($trees/*-*/*(:t))
@@ -175,7 +175,7 @@ _gentoo_packages_update_available(){
 _gentoo_packages_update_available_versions(){
   local var overlay_ebuilds portage_ebuilds expl trees category
 
-  PORTDIR=$(_gentoo_repos)
+  PORTDIR=$(_gentoo_repos -m)
   PORTDIR_OVERLAY=$(_gentoo_repos -o)
 
   trees=($PORTDIR $=PORTDIR_OVERLAY)

diff --git a/src/_gentoo_repos b/src/_gentoo_repos
index 3419cdc..7f88a64 100644
--- a/src/_gentoo_repos
+++ b/src/_gentoo_repos
@@ -1,40 +1,40 @@
 #autoload
 
 # Usage:
-#   _gentoo_repos    -> returns the main repo (with PORTDIR fallback)
-#   _gentoo_repos -o -> returns the list of non-main repos (with 
PORTDIR_OVERLAY fallback)
+#   _gentoo_repos    -> returns the list of all repos
+#   _gentoo_repos -m -> returns the main repo
+#   _gentoo_repos -o -> returns the list of non-main repos
 
 _gentoo_repos() {
-  local main_repo main_repo_path overlay overlay_path
+  local main_repo main_repo_path overlay overlay_paths
 
   if [[ -e /usr/share/portage/config/repos.conf ]]; then
-    if [[ ${1} == "-o" ]]; then
-      for overlay in $(_repos_conf -l); do
-        overlay_path+=($(_repos_conf ${overlay} location))
-      done
+    main_repo=$(_repos_conf DEFAULT main-repo)
+    main_repo_path=$(_repos_conf ${main_repo} location)
 
-      source /etc/make.conf 2>/dev/null
-      source /etc/portage/make.conf 2>/dev/null
+    for overlay in $(_repos_conf -l); do
+      overlay_paths+=($(_repos_conf ${overlay} location))
+    done
 
-      overlay_path+=(${(@)PORTDIR_OVERLAY})
-
-      echo "${(@u)overlay_path}"
-    else
-      main_repo=$(_repos_conf DEFAULT main-repo)
-      main_repo_path=$(_repos_conf ${main_repo} location)
+    source /etc/make.conf 2>/dev/null
+    source /etc/portage/make.conf 2>/dev/null
 
-      echo "${main_repo_path}"
-    fi
+    overlay_paths+=(${(@)PORTDIR_OVERLAY})
   else
     source /usr/share/portage/config/make.globals 2>/dev/null
     source /etc/make.conf 2>/dev/null
     source /etc/portage/make.conf 2>/dev/null
 
-    if [[ ${1} == "-o" ]]; then
-      echo "${(@u)PORTDIR_OVERLAY}"
-    else
-      echo "${PORTDIR}"
-    fi
+    main_repo_path="${PORTDIR}"
+    overlay_paths=(${(@)PORTDIR_OVERLAY})
+  fi
+
+  if [[ $1 == "-m" ]]; then
+    echo "${main_repo_path}"
+  elif [[ $1 == "-o" ]]; then
+    echo "${(@u)overlay_paths}"
+  else
+    echo "${main_repo_path} ${(@u)overlay_paths}"
   fi
 }
 

diff --git a/src/_portage_utils b/src/_portage_utils
index acff1a6..7fdb828 100644
--- a/src/_portage_utils
+++ b/src/_portage_utils
@@ -4,7 +4,7 @@
 
 local common_args PORTDIR
 
-PORTDIR="$(_gentoo_repos)"
+PORTDIR="$(_gentoo_repos -m)"
 
 common_args=(
   '--root[Set the ROOT env var]:root directory:_files -/' \

Reply via email to