From: David Aguilar Date: Sun, 24 Aug 2008 17:21:38 GMT Subject: [PATCH 1/3] git-submodule: add a get_remote function Message-ID: In-Reply-To: <1219598500-8334-1-git-send-email-davvid@gmail.com> get_remote finds the remote that corresponds to HEAD. This code is duplicated from resolve_relative_url but will be refactored and reused in subsequent commits. Signed-off-by: David Aguilar --- git-submodule.sh | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/git-submodule.sh b/git-submodule.sh index 2a3a197..9d2bddb 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -27,6 +27,15 @@ say() fi } +# Gets the remote corresponding to HEAD +get_remote() +{ + branch="$(git symbolic-ref HEAD 2>/dev/null)" + remote="$(git config branch.${branch#refs/heads/}.remote)" + remote="${remote:-origin}" + echo "$remote" +} + # Resolve relative url by appending to parent's url resolve_relative_url () { -- 1.6.0.90.g436ed