]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-submodule.sh
Merge branch 'maint' of git://repo.or.cz/git-gui into maint
[git.git] / git-submodule.sh
index c2ce2fbe8afa924f7f34970a3fb07363abe07452..5888735e4f2dac852f43c31195f430a1a6d23446 100755 (executable)
@@ -172,10 +172,20 @@ cmd_add()
                else
                        die "'$path' already exists and is not a valid git repo"
                fi
+
+               case "$repo" in
+               ./*|../*)
+                       url=$(resolve_relative_url "$repo") || exit
+                   ;;
+               *)
+                       url="$repo"
+                       ;;
+               esac
+               git config submodule."$path".url "$url"
        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
 
@@ -254,6 +264,7 @@ cmd_update()
        do
                case "$1" in
                -q|--quiet)
+                       shift
                        quiet=1
                        ;;
                -i|--init)
@@ -271,7 +282,6 @@ cmd_update()
                        break
                        ;;
                esac
-               shift
        done
 
        git ls-files --stage -- "$@" | grep '^160000 ' |
@@ -301,8 +311,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'"