From: Junio C Hamano Date: Thu, 16 Dec 2010 20:49:22 +0000 (-0800) Subject: Merge branch 'jn/submodule-b-current' X-Git-Tag: v1.7.4-rc0~39 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7eaf4af426ee29812d49cfa5328e2af8b3f8af95?hp=-c Merge branch 'jn/submodule-b-current' * jn/submodule-b-current: git submodule: Remove now obsolete tests before cloning a repo git submodule -b ... of current HEAD fails --- 7eaf4af426ee29812d49cfa5328e2af8b3f8af95 diff --combined git-submodule.sh index 33bc41f069,a84418f1aa..c21b77aee5 --- a/git-submodule.sh +++ b/git-submodule.sh @@@ -93,20 -93,6 +93,6 @@@ module_clone( url=$2 reference="$3" - # If there already is a directory at the submodule path, - # expect it to be empty (since that is the default checkout - # action) and try to remove it. - # Note: if $path is a symlink to a directory the test will - # succeed but the rmdir will fail. We might want to fix this. - if test -d "$path" - then - rmdir "$path" 2>/dev/null || - die "Directory '$path' exists, but is neither empty nor a git repository" - fi - - test -e "$path" && - die "A file already exist at path '$path'" - if test -n "$reference" then git-clone "$reference" -n "$url" "$path" @@@ -241,7 -227,7 +227,7 @@@ cmd_add( # ash fails to wordsplit ${branch:+-b "$branch"...} case "$branch" in '') git checkout -f -q ;; - ?*) git checkout -f -q -b "$branch" "origin/$branch" ;; + ?*) git checkout -f -q -B "$branch" "origin/$branch" ;; esac ) || die "Unable to checkout submodule '$path'" fi @@@ -374,35 -360,41 +360,35 @@@ cmd_init( cmd_update() { # parse $args after "submodule ... update". - orig_args="$@" + orig_flags= while test $# -ne 0 do case "$1" in -q|--quiet) - shift GIT_QUIET=1 ;; -i|--init) init=1 - shift ;; -N|--no-fetch) - shift nofetch=1 ;; -r|--rebase) - shift update="rebase" ;; --reference) case "$2" in '') usage ;; esac reference="--reference=$2" - shift 2 + orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")" + shift ;; --reference=*) reference="$1" - shift ;; -m|--merge) - shift update="merge" ;; --recursive) - shift recursive=1 ;; --) @@@ -416,8 -408,6 +402,8 @@@ break ;; esac + orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")" + shift done if test -n "$init" @@@ -496,7 -486,7 +482,7 @@@ if test -n "$recursive" then - (clear_local_git_env; cd "$path" && cmd_update $orig_args) || + (clear_local_git_env; cd "$path" && eval cmd_update "$orig_flags") || die "Failed to recurse into submodule path '$path'" fi done @@@ -729,7 -719,7 +715,7 @@@ cmd_summary() cmd_status() { # parse $args after "submodule ... status". - orig_args="$@" + orig_flags= while test $# -ne 0 do case "$1" in @@@ -753,7 -743,6 +739,7 @@@ break ;; esac + orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")" shift done @@@ -787,7 -776,7 +773,7 @@@ prefix="$displaypath/" clear_local_git_env cd "$path" && - cmd_status $orig_args + eval cmd_status "$orig_args" ) || die "Failed to recurse into submodule path '$path'" fi @@@ -833,12 -822,11 +819,12 @@@ cmd_sync( ;; esac + say "Synchronizing submodule url for '$name'" + git config submodule."$name".url "$url" + if test -e "$path"/.git then ( - say "Synchronizing submodule url for '$name'" - git config submodule."$name".url "$url" clear_local_git_env cd "$path" remote=$(get_default_remote)