summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2021-03-03 15:15:44 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2021-03-03 15:15:44 +0900
commit8a118ec5a23c80fc98af03d0fdd6220b7dc9c5c3 (patch)
treec1099f20cc1b0be3ca1a45a369194fa58866e959 /git-submodule.sh
parent8f238fcbc37ccbcf765aa7b7a8dfa93994ed935d (diff)
downloadgit-8a118ec5a23c80fc98af03d0fdd6220b7dc9c5c3.tar.gz
git-8a118ec5a23c80fc98af03d0fdd6220b7dc9c5c3.tar.bz2
git-8a118ec5a23c80fc98af03d0fdd6220b7dc9c5c3.zip
Imported Upstream version 2.8.0upstream/2.8.0
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh29
1 files changed, 26 insertions, 3 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 9bc5c5f9..43c68dee 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -591,6 +591,24 @@ cmd_deinit()
done
}
+is_tip_reachable () (
+ clear_local_git_env
+ cd "$1" &&
+ rev=$(git rev-list -n 1 "$2" --not --all 2>/dev/null) &&
+ test -z "$rev"
+)
+
+fetch_in_submodule () (
+ clear_local_git_env
+ cd "$1" &&
+ case "$2" in
+ '')
+ git fetch ;;
+ *)
+ git fetch $(get_default_remote) "$2" ;;
+ esac
+)
+
#
# Update each submodule path to correct revision, using clone and checkout as needed
#
@@ -745,10 +763,15 @@ Maybe you want to use 'update --init'?")"
then
# Run fetch only if $sha1 isn't present or it
# is not reachable from a ref.
- (clear_local_git_env; cd "$sm_path" &&
- ( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
- test -z "$rev") || git-fetch)) ||
+ is_tip_reachable "$sm_path" "$sha1" ||
+ fetch_in_submodule "$sm_path" ||
die "$(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
+ is_tip_reachable "$sm_path" "$sha1" ||
+ fetch_in_submodule "$sm_path" "$sha1" ||
+ die "$(eval_gettext "Fetched in submodule path '\$displaypath', but it did not contain $sha1. Direct fetching of that commit failed.")"
fi
# Is this something we just cloned?