X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=git-submodule.sh;h=65178ae8e32bb20c65c42eb9668fb0ffec749007;hb=78a935d48b28ebf5b1af348d7e57763f2955afd1;hp=1c39b593a628cc94d24d227cc5d92e00ac5e71ed;hpb=11bd3ddb913afd9665e7e822ea54be4fc8d2d5ea;p=git.git diff --git a/git-submodule.sh b/git-submodule.sh index 1c39b593a..65178ae8e 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -194,7 +194,7 @@ cmd_add() else module_clone "$path" "$realrepo" || exit - (unset GIT_DIR; cd "$path" && git checkout -q ${branch:+-b "$branch" "origin/$branch"}) || + (unset GIT_DIR; cd "$path" && git checkout -f -q ${branch:+-b "$branch" "origin/$branch"}) || die "Unable to checkout submodule '$path'" fi @@ -340,8 +340,13 @@ cmd_update() if test "$subsha1" != "$sha1" then + force= + if test -z "$subsha1" + then + force="-f" + fi (unset GIT_DIR; cd "$path" && git-fetch && - git-checkout -q "$sha1") || + git-checkout $force -q "$sha1") || die "Unable to checkout '$sha1' in submodule path '$path'" say "Submodule path '$path': checked out '$sha1'" @@ -634,6 +639,14 @@ cmd_sync() do name=$(module_name "$path") url=$(git config -f .gitmodules --get submodule."$name".url) + + # Possibly a url relative to parent + case "$url" in + ./*|../*) + url=$(resolve_relative_url "$url") || exit + ;; + esac + if test -e "$path"/.git then (