[PATCH 1/3] git-submodule: add a get_remote function
- From
David Aguilar <davvid@gmail.com>
- Date
- Aug 24, 2008, 17:21 UTC
- Message-ID
- <e21617f50ffaae98ab73fa364e40440397bcbe33.1219598198.git.davvid@gmail.com>
- 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 <davvid@gmail.com> --- 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