From 39a793af0ab13a19537271deae55609203a7c41c Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sat, 29 Sep 2012 23:17:39 -0400 Subject: [PATCH] Simplify git-config calls --- modules/git/functions/_git-hub-browse | 8 +++----- modules/git/functions/git-hub-browse | 7 ++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/git/functions/_git-hub-browse b/modules/git/functions/_git-hub-browse index f54daeb..e3c41d8 100644 --- a/modules/git/functions/_git-hub-browse +++ b/modules/git/functions/_git-hub-browse @@ -17,17 +17,15 @@ _arguments -C -s -S \ case "$state" in (remote) - remotes=($( - git config --local --get-regexp 'remote.*.url' \ - | awk 'BEGIN {FS="."} ; {print $2}' - )) + remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2)) + _describe -t branch 'remotes' remotes && ret=0 ;; (branch-or-tag) remote="$words[(($CURRENT - 1))]" branches_or_tags=($( - git ls-remote --heads --tags "$remote" | awk '{print $2}' + git ls-remote --heads --tags "$remote" 2>/dev/null | cut -f2 )) branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/}) diff --git a/modules/git/functions/git-hub-browse b/modules/git/functions/git-hub-browse index bc2a070..ee4f9f6 100644 --- a/modules/git/functions/git-hub-browse +++ b/modules/git/functions/git-hub-browse @@ -8,10 +8,7 @@ local remotes remote references reference file url remote="${1:-origin}" -remotes=($( - git config --local --get-regexp 'remote.*.url' \ - | awk 'BEGIN {FS="."} ; {print $2}' -)) +remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2)) if (( $remotes[(i)$remote] == $#remotes + 1 )); then print "$0: remote not found: $remote" >&2 @@ -19,7 +16,7 @@ if (( $remotes[(i)$remote] == $#remotes + 1 )); then fi url=$( - git config --local --get "remote.${remote}.url" \ + git config --get "remote.${remote}.url" \ | sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p" )