diff options
| author | Junio C Hamano <gitster@pobox.com> | 2020-12-03 00:18:06 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-12-03 00:18:06 -0800 |
| commit | e89ecfbb13f600e7fc0272c29de432e424a97aaa (patch) | |
| tree | 40f144363d3d524f689d25c5ca68b7314b5c95a5 /git-submodule.sh | |
| parent | 72ffeb997eaf999f6938b2a7e0d9a75dcceaa311 (diff) | |
| parent | 66d36b94af6351d1e9b68a871d5faeb8a27d8a33 (diff) | |
| download | git-e89ecfbb13f600e7fc0272c29de432e424a97aaa.tar.gz | |
Merge branch 'ab/retire-parse-remote'
"git-parse-remote" shell script library outlived its usefulness.
* ab/retire-parse-remote:
submodule: fix fetch_in_submodule logic
parse-remote: remove this now-unused library
submodule: remove sh function in favor of helper
submodule: use "fetch" logic instead of custom remote discovery
Diffstat (limited to 'git-submodule.sh')
| -rwxr-xr-x | git-submodule.sh | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/git-submodule.sh b/git-submodule.sh index 7ce52872b7..eb90f18229 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,16 +412,18 @@ is_tip_reachable () ( test -z "$rev" ) +# usage: fetch_in_submodule <module_path> [<depth>] [<sha1>] +# Because arguments are positional, use an empty string to omit <depth> +# but include <sha1>. fetch_in_submodule () ( sanitize_submodule_env && cd "$1" && - case "$2" in - '') - git fetch ;; - *) - shift - git fetch $(get_default_remote) "$@" ;; - esac + if test $# -eq 3 + then + echo "$3" | git fetch --stdin ${2:+"$2"} + else + git fetch ${2:+"$2"} + fi ) # @@ -576,7 +577,7 @@ cmd_update() fetch_in_submodule "$sm_path" $depth || die "$(eval_gettext "Unable to fetch in submodule path '\$sm_path'")" fi - remote_name=$(sanitize_submodule_env; cd "$sm_path" && get_default_remote) + remote_name=$(sanitize_submodule_env; cd "$sm_path" && git submodule--helper print-default-remote) sha1=$(sanitize_submodule_env; cd "$sm_path" && git rev-parse --verify "${remote_name}/${branch}") || die "$(eval_gettext "Unable to find current \${remote_name}/\${branch} revision in submodule path '\$sm_path'")" @@ -602,7 +603,7 @@ cmd_update() # Now we tried the usual fetch, but $sha1 may # not be reachable from any of the refs is_tip_reachable "$sm_path" "$sha1" || - fetch_in_submodule "$sm_path" $depth "$sha1" || + fetch_in_submodule "$sm_path" "$depth" "$sha1" || die "$(eval_gettext "Fetched in submodule path '\$displaypath', but it did not contain \$sha1. Direct fetching of that commit failed.")" fi |
