summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-04-04 15:02:01 -0700
committerJunio C Hamano <gitster@pobox.com>2011-04-04 15:02:01 -0700
commit2071fb015bc673d2514142d7614b56a37b3faaf2 (patch)
tree8bd133ee781324212c8ebc395178d20707082ae2 /git-submodule.sh
parent2c320e71bfae3d2972d41680a04b78cbd42cb941 (diff)
parent794a3592ad9d8a9b273f6496052bbcb46b1924ed (diff)
downloadgit-2071fb015bc673d2514142d7614b56a37b3faaf2.tar.gz
Merge branch 'jl/submodule-fetch-on-demand'
* jl/submodule-fetch-on-demand: fetch/pull: Describe --recurse-submodule restrictions in the BUGS section submodule update: Don't fetch when the submodule commit is already present fetch/pull: Don't recurse into a submodule when commits are already present Submodules: Add 'on-demand' value for the 'fetchRecurseSubmodule' option config: teach the fetch.recurseSubmodules option the 'on-demand' value fetch/pull: Add the 'on-demand' value to the --recurse-submodules option fetch/pull: recurse into submodules when necessary Conflicts: builtin/fetch.c submodule.c
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 7f6b3cf207..b010a67309 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