Subject: [PATCH v2 1/2] parse-remote: move used code to git-submodule.sh

From: Junio C Hamano <[email-masked]>
Date: Thu, 12 Nov 2020 12:31:54 -0800

From: Ævar Arnfjörð Bjarmason <[email-masked]>

Move the get_default_remote () helper from git-parse-remote.sh to
git-submodule.sh, as the latter is the only user.

There are two more helper functions, get_remote_merge_branch() and
error_on_missing_default_upstream(), in the git-parse-remote shell
function library, but they are not referenced by git-submodule.sh;
stop dot-sourcing the git-parse-remote.

Signed-off-by: Ævar Arnfjörð Bjarmason <[email-masked]>
Signed-off-by: Junio C Hamano <[email-masked]>
---
 git-parse-remote.sh | 7 -------
 git-submodule.sh    | 8 +++++++-
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index d3c39980f3..0c2a5ef6c4 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -6,13 +6,6 @@
 # this would fail in that case and would issue an error message.
 GIT_DIR=$(git rev-parse -q --git-dir) || :;
 
-get_default_remote () {
-	curr_branch=$(git symbolic-ref -q HEAD)
-	curr_branch="${curr_branch#refs/heads/}"
-	origin=$(git config --get "branch.$curr_branch.remote")
-	echo ${origin:-origin}
-}
-
 get_remote_merge_branch () {
 	case "$#" in
 	0|1)
diff --git a/git-submodule.sh b/git-submodule.sh
index 7ce52872b7..e7962e1a45 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -20,7 +20,6 @@ USAGE="[--quiet] [--cached]
 OPTIONS_SPEC=
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
-. git-parse-remote
 require_work_tree
 wt_prefix=$(git rev-parse --show-prefix)
 cd_to_toplevel
@@ -413,6 +412,13 @@ is_tip_reachable () (
 	test -z "$rev"
 )
 
+get_default_remote () {
+	curr_branch=$(git symbolic-ref -q HEAD)
+	curr_branch="${curr_branch#refs/heads/}"
+	origin=$(git config --get "branch.$curr_branch.remote")
+	echo ${origin:-origin}
+}
+
 fetch_in_submodule () (
 	sanitize_submodule_env &&
 	cd "$1" &&
-- 
2.29.2-442-ga30192deef