diff mbox series

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

Message ID 20201112203155.3342586-2-gitster@pobox.com (mailing list archive)
State New, archived
Headers show
Series Retire git-parse-remote | expand

Commit Message

Junio C Hamano Nov. 12, 2020, 8:31 p.m. UTC
From: Ævar Arnfjörð Bjarmason <avarab@gmail.com>

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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-parse-remote.sh | 7 -------
 git-submodule.sh    | 8 +++++++-
 2 files changed, 7 insertions(+), 8 deletions(-)
diff mbox series

Patch

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" &&