Merge branch 'sb/submodule-update-try-harder'
authorJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 05:04:12 +0000 (14:04 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 05:04:12 +0000 (14:04 +0900)
"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

1  2 
git-submodule.sh
diff --combined git-submodule.sh
index fd0fe081a81530c61480104d5ce6d84e9e4ea371,00fcd69138fd649e467a49523549978ed8d518b7..78073cd87d1b1775bb4f4264557aba18c73c5911
@@@ -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
                --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
                --reference=*)
                        reference="$1"
                        ;;
 +              --dissociate)
 +                      dissociate=1
 +                      ;;
                -m|--merge)
                        update="merge"
                        ;;
  
        {
        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=
                                # 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