Merge branch 'jl/submodule-rm'
[git.git] / git-submodule.sh
index 3d1617fa9eb490463f9a4a4218082de168e1491a..2365149d0b920ece4d076dafbebf23fef6888df1 100755 (executable)
@@ -5,13 +5,13 @@
 # Copyright (c) 2007 Lars Hjemli
 
 dashless=$(basename "$0" | sed -e 's/-/ /')
-USAGE="[--quiet] add [-b branch] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
+USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
    or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
    or: $dashless [--quiet] init [--] [<path>...]
    or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
    or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
    or: $dashless [--quiet] foreach [--recursive] <command>
-   or: $dashless [--quiet] sync [--] [<path>...]"
+   or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
 OPTIONS_SPEC=
 . git-sh-setup
 . git-sh-i18n
@@ -950,7 +950,6 @@ cmd_summary() {
 cmd_status()
 {
        # parse $args after "submodule ... status".
-       orig_flags=
        while test $# -ne 0
        do
                case "$1" in
@@ -974,7 +973,6 @@ cmd_status()
                        break
                        ;;
                esac
-               orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")"
                shift
        done
 
@@ -1014,7 +1012,7 @@ cmd_status()
                                prefix="$displaypath/"
                                clear_local_git_env
                                cd "$sm_path" &&
-                               eval cmd_status "$orig_args"
+                               eval cmd_status
                        ) ||
                        die "$(eval_gettext "Failed to recurse into submodule path '\$sm_path'")"
                fi
@@ -1034,6 +1032,10 @@ cmd_sync()
                        GIT_QUIET=1
                        shift
                        ;;
+               --recursive)
+                       recursive=1
+                       shift
+                       ;;
                --)
                        shift
                        break
@@ -1075,7 +1077,7 @@ cmd_sync()
 
                if git config "submodule.$name.url" >/dev/null 2>/dev/null
                then
-                       say "$(eval_gettext "Synchronizing submodule url for '\$name'")"
+                       say "$(eval_gettext "Synchronizing submodule url for '\$prefix\$sm_path'")"
                        git config submodule."$name".url "$super_config_url"
 
                        if test -e "$sm_path"/.git
@@ -1085,6 +1087,12 @@ cmd_sync()
                                cd "$sm_path"
                                remote=$(get_default_remote)
                                git config remote."$remote".url "$sub_origin_url"
+
+                               if test -n "$recursive"
+                               then
+                                       prefix="$prefix$sm_path/"
+                                       eval cmd_sync
+                               fi
                        )
                        fi
                fi