Merge branch 'jl/submodule-update-quiet' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 16 Aug 2011 19:41:14 +0000 (12:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 Aug 2011 19:41:14 +0000 (12:41 -0700)
* jl/submodule-update-quiet:
submodule: update and add must honor --quiet flag

1  2 
git-submodule.sh
t/t7400-submodule-basic.sh
diff --combined git-submodule.sh
index f8ea3bf6f2bc4310fd0cfcf212f89c1e06ee8f33,11eab508024037c92daab0af776579e4545a143e..c94218b8779be63e1441480ef3828fb4ce0b61b0
@@@ -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
                        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
                                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
  }
index 662fe91295262976c2a541d296194d3d2e9dcc5f,f086db10731b147a722686efd5e2d19c7be72dd1..c22916ddd91c8a2aee33b8a25f55def0c93b587b
@@@ -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 &&
        (