Skip to content

Commit 1c15180

Browse files
avargitster
authored andcommitted
submodule: use "fetch" logic instead of custom remote discovery
Replace a use of the get_default_remote() function with an invocation of "git fetch" The "fetch" command already has logic to discover the remote for the current branch. However, before it learned to accept a custom refspec *and* use its idea of the default remote, it wasn't possible to get rid of some equivalent of the "get_default_remote" invocation here. As it turns out the recently added "--stdin" option to fetch[1] gives us a way to do that. Let's use it instead. While I'm at it simplify the "fetch_in_submodule" function. It wasn't necessary to pass "$@" to "fetch" since we'd only ever provide one SHA-1 as an argument in the previous "*" codepath (in addition to "--depth=N"). Rewrite the function to more narrowly reflect its use-case. 1. https://lore.kernel.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 898f807 commit 1c15180

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

git-submodule.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,15 @@ is_tip_reachable () (
416416
fetch_in_submodule () (
417417
sanitize_submodule_env &&
418418
cd "$1" &&
419-
case "$2" in
420-
'')
421-
git fetch ;;
422-
*)
423-
shift
424-
git fetch $(get_default_remote) "$@" ;;
425-
esac
419+
if test $# -eq 3
420+
then
421+
echo "$3" | git fetch --stdin "$2"
422+
elif test "$2" -ne ""
423+
then
424+
git fetch "$2"
425+
else
426+
git fetch
427+
fi
426428
)
427429

428430
#

0 commit comments

Comments
 (0)