From 224dc2eafff0db2717e03855005ccc42f11a4029 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 24 Sep 2012 01:46:24 -0400 Subject: [PATCH] Use Git porcelain commands in git-hub --- modules/git/functions/_git-hub | 13 +++++-------- modules/git/functions/git-hub | 8 ++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/modules/git/functions/_git-hub b/modules/git/functions/_git-hub index ac17fd2..abefd03 100644 --- a/modules/git/functions/_git-hub +++ b/modules/git/functions/_git-hub @@ -18,19 +18,16 @@ _arguments -C -s -S \ case "$state" in (remote) remotes=($( - git config -l \ - | grep 'remote\.[^.]*\.url' \ - | cut -d'.' -f2)) + git config --local --get-regexp 'remote.*.url' \ + | awk 'BEGIN {FS="."} ; {print $2}' + )) _describe -t branch 'remotes' remotes && ret=0 ;; (branch) remote="$words[(($CURRENT - 1))]" branches=($( - git branch -r \ - | grep "${remote}/" \ - | sed \ - -e "/${remote}\/HEAD -> ${remote}/d" \ - -e "s/^[[:space:]]*${remote}\///g" + git ls-remote --heads "$remote" \ + | awk '{gsub(/refs\/heads\//, "", $2)} ; {print $2}' )) _describe -t branch 'branches' branches && ret=0 ;; diff --git a/modules/git/functions/git-hub b/modules/git/functions/git-hub index 8d2e494..95a7d52 100644 --- a/modules/git/functions/git-hub +++ b/modules/git/functions/git-hub @@ -9,12 +9,12 @@ local remote branches branch current_branch file url remote="${1:-origin}" url=$( - git config -l \ - | grep "remote.${remote}.url" \ - | sed -En "s/remote.${remote}.url=(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p" + git config --local --get "remote.${remote}.url" \ + | sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p" ) branches=($( - git branch -r | sed -e "/${remote}\/HEAD -> ${remote}/d" -e "s/^[[:space:]]*${remote}\///g" + git ls-remote --heads "$remote" \ + | awk '{gsub(/refs\/heads\//, "", $2)} ; {print $2}' )) current_branch="$(git-branch-current)" branch="${2:-master}"