From: Junio C Hamano Date: Tue, 16 Aug 2011 19:41:14 +0000 (-0700) Subject: Merge branch 'jl/submodule-update-quiet' into maint X-Git-Tag: v1.7.6.1~14 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1320352501a73a91d77b7865993f322026d056d7?hp=-c Merge branch 'jl/submodule-update-quiet' into maint * jl/submodule-update-quiet: submodule: update and add must honor --quiet flag --- 1320352501a73a91d77b7865993f322026d056d7 diff --combined git-submodule.sh index f8ea3bf6f2,11eab50802..c94218b877 --- a/git-submodule.sh +++ b/git-submodule.sh @@@ -34,7 -34,7 +34,7 @@@ resolve_relative_url ( { remote=$(get_default_remote) remoteurl=$(git config "remote.$remote.url") || - die "remote ($remote) does not have a url defined in .git/config" + remoteurl=$(pwd) # the repository is its own authoritative upstream url="$1" remoteurl=${remoteurl%/} sep=/ @@@ -121,12 -121,17 +121,17 @@@ module_clone( path=$1 url=$2 reference="$3" + quiet= + if test -n "$GIT_QUIET" + then + quiet=-q + fi if test -n "$reference" then - git-clone "$reference" -n "$url" "$path" + git-clone $quiet "$reference" -n "$url" "$path" else - git-clone -n "$url" "$path" + git-clone $quiet -n "$url" "$path" fi || die "Clone of '$url' into submodule path '$path' failed" } @@@ -238,6 -243,15 +243,6 @@@ cmd_add( 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" "$reference" || exit @@@ -251,7 -265,6 +256,7 @@@ esac ) || die "Unable to checkout submodule '$path'" fi + git config submodule."$path".url "$realrepo" git add $force "$path" || die "Failed to add submodule '$path'" @@@ -292,10 -305,6 +297,10 @@@ cmd_foreach( toplevel=$(pwd) + # dup stdin so that it can be restored when running the external + # command in the subshell (and a recursive call to this function) + exec 3<&0 + module_list | while read mode sha1 stage path do @@@ -312,7 -321,7 +317,7 @@@ then cmd_foreach "--recursive" "$@" fi - ) || + ) <&3 3<&- || die "Stopping at '$path'; script returned non-zero status." fi done @@@ -351,26 -360,25 +356,26 @@@ cmd_init( do # Skip already registered paths name=$(module_name "$path") || exit - url=$(git config submodule."$name".url) - test -z "$url" || continue - - url=$(git config -f .gitmodules submodule."$name".url) - test -z "$url" && - die "No url found for submodule path '$path' in .gitmodules" - - # Possibly a url relative to parent - case "$url" in - ./*|../*) - url=$(resolve_relative_url "$url") || exit - ;; - esac - - git config submodule."$name".url "$url" || - die "Failed to register url for submodule path '$path'" + if test -z "$(git config "submodule.$name.url")" + then + url=$(git config -f .gitmodules submodule."$name".url) + test -z "$url" && + die "No url found for submodule path '$path' in .gitmodules" + + # Possibly a url relative to parent + case "$url" in + ./*|../*) + url=$(resolve_relative_url "$url") || exit + ;; + esac + git config submodule."$name".url "$url" || + die "Failed to register url for submodule path '$path'" + fi + # Copy "update" setting when it is not set yet upd="$(git config -f .gitmodules submodule."$name".update)" test -z "$upd" || + test -n "$(git config submodule."$name".update)" || git config submodule."$name".update "$upd" || die "Failed to register update mode for submodule path '$path'" @@@ -871,20 -879,17 +876,20 @@@ cmd_sync( ;; esac - say "Synchronizing submodule url for '$name'" - git config submodule."$name".url "$url" - - if test -e "$path"/.git + if git config "submodule.$name.url" >/dev/null 2>/dev/null then - ( - clear_local_git_env - cd "$path" - remote=$(get_default_remote) - git config remote."$remote".url "$url" - ) + say "Synchronizing submodule url for '$name'" + git config submodule."$name".url "$url" + + if test -e "$path"/.git + then + ( + clear_local_git_env + cd "$path" + remote=$(get_default_remote) + git config remote."$remote".url "$url" + ) + fi fi done } diff --combined t/t7400-submodule-basic.sh index 662fe91295,f086db1073..c22916ddd9 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@@ -47,10 -47,8 +47,10 @@@ test_expect_success 'setup - repositor ' # The 'submodule add' tests need some repository to add as a submodule. -# The trash directory is a good one as any. -submodurl=$TRASH_DIRECTORY +# The trash directory is a good one as any. We need to canonicalize +# the name, though, as some tests compare it to the absolute path git +# generates, which will expand symbolic links. +submodurl=$(pwd -P) listbranches() { git for-each-ref --format='%(refname)' 'refs/heads/*' @@@ -77,7 -75,8 +77,8 @@@ test_expect_success 'submodule add' ( cd addtest && - git submodule add "$submodurl" submod && + git submodule add -q "$submodurl" submod >actual && + test ! -s actual && git submodule init ) && @@@ -275,7 -274,8 +276,8 @@@ test_expect_success 'update should wor echo "$rev1" >expect && mkdir init && - git submodule update && + git submodule update -q >update.out && + test ! -s update.out && inspect init && test_cmp expect head-sha1 @@@ -448,16 -448,6 +450,16 @@@ test_expect_success 'add should fail wh ) ' +test_expect_success 'use superproject as upstream when path is relative and no url is set there' ' + ( + cd addtest && + git submodule add ../repo relative && + test "$(git config -f .gitmodules submodule.relative.url)" = ../repo && + git submodule sync relative && + test "$(git config submodule.relative.url)" = "$submodurl/repo" + ) +' + test_expect_success 'set up for relative path tests' ' mkdir reltest && (