From: Junio C Hamano Date: Wed, 30 May 2018 05:04:12 +0000 (+0900) Subject: Merge branch 'sb/submodule-update-try-harder' X-Git-Tag: v2.18.0-rc0~13 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a173dddf4483ed11b228077078becc8b65174b46?ds=inline;hp=-c Merge branch 'sb/submodule-update-try-harder' "git submodule update" attempts two different kinds of "git fetch" against the upstream repository to grab a commit bound at the submodule's path, but it incorrectly gave up if the first kind (i.e. a normal fetch) failed, making the second "last resort" one (i.e. fetching an exact commit object by object name) ineffective. This has been corrected. * sb/submodule-update-try-harder: git-submodule.sh: try harder to fetch a submodule --- a173dddf4483ed11b228077078becc8b65174b46 diff --combined git-submodule.sh index fd0fe081a8,00fcd69138..78073cd87d --- a/git-submodule.sh +++ b/git-submodule.sh @@@ -42,7 -42,6 +42,7 @@@ prefix custom_name= depth= progress= +dissociate= die_if_unmatched () { @@@ -118,9 -117,6 +118,9 @@@ cmd_add( -q|--quiet) GIT_QUIET=1 ;; + --progress) + progress=1 + ;; --reference) case "$2" in '') usage ;; esac reference_path=$2 @@@ -129,9 -125,6 +129,9 @@@ --reference=*) reference_path="${1#--reference=}" ;; + --dissociate) + dissociate=1 + ;; --name) case "$2" in '') usage ;; esac custom_name=$2 @@@ -236,11 -229,6 +236,11 @@@ Use -f if you really want to add it." > sm_name="$sm_path" fi + if ! git submodule--helper check-name "$sm_name" + then + die "$(eval_gettext "'$sm_name' is not a valid submodule name")" + fi + # perhaps the path exists and is already a git repo, else clone it if test -e "$sm_path" then @@@ -267,7 -255,7 +267,7 @@@ or you are unsure what this means choos eval_gettextln "Reactivating local git directory for submodule '\$sm_name'." fi fi - git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${depth:+"$depth"} || exit + git submodule--helper clone ${GIT_QUIET:+--quiet} ${progress:+"--progress"} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${dissociate:+"--dissociate"} ${depth:+"$depth"} || exit ( sanitize_submodule_env cd "$sm_path" && @@@ -477,7 -465,7 +477,7 @@@ cmd_update( GIT_QUIET=1 ;; --progress) - progress="--progress" + progress=1 ;; -i|--init) init=1 @@@ -502,9 -490,6 +502,9 @@@ --reference=*) reference="$1" ;; + --dissociate) + dissociate=1 + ;; -m|--merge) update="merge" ;; @@@ -557,15 -542,14 +557,15 @@@ { git submodule--helper update-clone ${GIT_QUIET:+--quiet} \ - ${progress:+"$progress"} \ + ${progress:+"--progress"} \ ${wt_prefix:+--prefix "$wt_prefix"} \ ${prefix:+--recursive-prefix "$prefix"} \ ${update:+--update "$update"} \ ${reference:+"$reference"} \ + ${dissociate:+"--dissociate"} \ ${depth:+--depth "$depth"} \ - ${recommend_shallow:+"$recommend_shallow"} \ - ${jobs:+$jobs} \ + $recommend_shallow \ + $jobs \ "$@" || echo "#unmatched" $? } | { err= @@@ -630,7 -614,7 +630,7 @@@ # is not reachable from a ref. is_tip_reachable "$sm_path" "$sha1" || fetch_in_submodule "$sm_path" $depth || - die "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'")" + say "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'")" # Now we tried the usual fetch, but $sha1 may # not be reachable from any of the refs