summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh5
1 files changed, 4 insertions, 1 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index 7f6b3cf..4361ae4 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -488,8 +488,11 @@ cmd_update()
if test -z "$nofetch"
then
+ # Run fetch only if $sha1 isn't present or it
+ # is not reachable from a ref.
(clear_local_git_env; cd "$path" &&
- git-fetch) ||
+ ( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
+ test -z "$rev") || git-fetch)) ||
die "Unable to fetch in submodule path '$path'"
fi