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@xxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html