Merge branch 'sb/submodule-parallel-update'
authorJunio C Hamano <gitster@pobox.com>
Wed, 23 Aug 2017 21:13:14 +0000 (14:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Aug 2017 21:13:14 +0000 (14:13 -0700)
Code clean-up.

* sb/submodule-parallel-update:
submodule.sh: remove unused variable

1  2 
git-submodule.sh
diff --combined git-submodule.sh
index ffa2d66481ab2182a336082bb996d9b3bce32589,6703fe9429221700d11cbbc0985bfda0c7ee4f8d..66d1ae8ef6c5f12c856a2f88eabce515dcafd489
@@@ -213,8 -213,7 +213,8 @@@ cmd_add(
                die "$(eval_gettext "'\$sm_path' already exists in the index and is not a submodule")"
        fi
  
 -      if test -z "$force" && ! git add --dry-run --ignore-missing "$sm_path" > /dev/null 2>&1
 +      if test -z "$force" &&
 +              ! git add --dry-run --ignore-missing --no-warn-embedded-repo "$sm_path" > /dev/null 2>&1
        then
                eval_gettextln "The following path is ignored by one of your .gitignore files:
  \$sm_path
@@@ -268,7 -267,7 +268,7 @@@ or you are unsure what this means choos
        fi
        git config submodule."$sm_name".url "$realrepo"
  
 -      git add $force "$sm_path" ||
 +      git add --no-warn-embedded-repo $force "$sm_path" ||
        die "$(eval_gettext "Failed to add submodule '\$sm_path'")"
  
        git config -f .gitmodules submodule."$sm_name".path "$sm_path" &&
        fi &&
        git add --force .gitmodules ||
        die "$(eval_gettext "Failed to register submodule '\$sm_path'")"
 +
 +      # NEEDSWORK: In a multi-working-tree world, this needs to be
 +      # set in the per-worktree config.
 +      if git config --get submodule.active >/dev/null
 +      then
 +              # If the submodule being adding isn't already covered by the
 +              # current configured pathspec, set the submodule's active flag
 +              if ! git submodule--helper is-active "$sm_path"
 +              then
 +                      git config submodule."$sm_name".active "true"
 +              fi
 +      else
 +              git config submodule."$sm_name".active "true"
 +      fi
  }
  
  #
@@@ -333,7 -318,7 +333,7 @@@ cmd_foreach(
                git submodule--helper list --prefix "$wt_prefix" ||
                echo "#unmatched" $?
        } |
 -      while read mode sha1 stage sm_path
 +      while read -r mode sha1 stage sm_path
        do
                die_if_unmatched "$mode" "$sha1"
                if test -e "$sm_path"/.git
@@@ -442,7 -427,7 +442,7 @@@ cmd_deinit(
                git submodule--helper list --prefix "$wt_prefix" "$@" ||
                echo "#unmatched" $?
        } |
 -      while read mode sha1 stage sm_path
 +      while read -r mode sha1 stage sm_path
        do
                die_if_unmatched "$mode" "$sha1"
                name=$(git submodule--helper name "$sm_path") || exit
@@@ -606,12 -591,11 +606,11 @@@ cmd_update(
                "$@" || echo "#unmatched" $?
        } | {
        err=
 -      while read mode sha1 stage just_cloned sm_path
 +      while read -r mode sha1 stage just_cloned sm_path
        do
                die_if_unmatched "$mode" "$sha1"
  
                name=$(git submodule--helper name "$sm_path") || exit
-               url=$(git config submodule."$name".url)
                if ! test -z "$update"
                then
                        update_module=$update
@@@ -848,7 -832,7 +847,7 @@@ cmd_summary() 
        # Get modified modules cared by user
        modules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- "$@" |
                sane_egrep '^:([0-7]* )?160000' |
 -              while read mod_src mod_dst sha1_src sha1_dst status sm_path
 +              while read -r mod_src mod_dst sha1_src sha1_dst status sm_path
                do
                        # Always show modules deleted or type-changed (blob<->module)
                        if test "$status" = D || test "$status" = T
                                test $status != A && test $ignore_config = all && continue
                        fi
                        # Also show added or modified modules which are checked out
 -                      GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
 +                      GIT_DIR="$sm_path/.git" git rev-parse --git-dir >/dev/null 2>&1 &&
                        printf '%s\n' "$sm_path"
                done
        )
        git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- $modules |
        sane_egrep '^:([0-7]* )?160000' |
        cut -c2- |
 -      while read mod_src mod_dst sha1_src sha1_dst status name
 +      while read -r mod_src mod_dst sha1_src sha1_dst status name
        do
                if test -z "$cached" &&
                        test $sha1_dst = 0000000000000000000000000000000000000000
                missing_dst=
  
                test $mod_src = 160000 &&
 -              ! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_src^0 >/dev/null &&
 +              ! GIT_DIR="$name/.git" git rev-parse -q --verify $sha1_src^0 >/dev/null &&
                missing_src=t
  
                test $mod_dst = 160000 &&
 -              ! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_dst^0 >/dev/null &&
 +              ! GIT_DIR="$name/.git" git rev-parse -q --verify $sha1_dst^0 >/dev/null &&
                missing_dst=t
  
                display_name=$(git submodule--helper relative-path "$name" "$wt_prefix")
@@@ -1021,17 -1005,18 +1020,17 @@@ cmd_status(
                git submodule--helper list --prefix "$wt_prefix" "$@" ||
                echo "#unmatched" $?
        } |
 -      while read mode sha1 stage sm_path
 +      while read -r mode sha1 stage sm_path
        do
                die_if_unmatched "$mode" "$sha1"
                name=$(git submodule--helper name "$sm_path") || exit
 -              url=$(git config submodule."$name".url)
                displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
                if test "$stage" = U
                then
                        say "U$sha1 $displaypath"
                        continue
                fi
 -              if test -z "$url" ||
 +              if ! git submodule--helper is-active "$sm_path" ||
                {
                        ! test -d "$sm_path"/.git &&
                        ! test -f "$sm_path"/.git
@@@ -1101,16 -1086,9 +1100,16 @@@ cmd_sync(
                git submodule--helper list --prefix "$wt_prefix" "$@" ||
                echo "#unmatched" $?
        } |
 -      while read mode sha1 stage sm_path
 +      while read -r mode sha1 stage sm_path
        do
                die_if_unmatched "$mode" "$sha1"
 +
 +              # skip inactive submodules
 +              if ! git submodule--helper is-active "$sm_path"
 +              then
 +                      continue
 +              fi
 +
                name=$(git submodule--helper name "$sm_path")
                url=$(git config -f .gitmodules --get submodule."$name".url)
  
                        ;;
                esac
  
 -              if git config "submodule.$name.url" >/dev/null 2>/dev/null
 +              displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
 +              say "$(eval_gettext "Synchronizing submodule url for '\$displaypath'")"
 +              git config submodule."$name".url "$super_config_url"
 +
 +              if test -e "$sm_path"/.git
                then
 -                      displaypath=$(git submodule--helper relative-path "$prefix$sm_path" "$wt_prefix")
 -                      say "$(eval_gettext "Synchronizing submodule url for '\$displaypath'")"
 -                      git config submodule."$name".url "$super_config_url"
 +              (
 +                      sanitize_submodule_env
 +                      cd "$sm_path"
 +                      remote=$(get_default_remote)
 +                      git config remote."$remote".url "$sub_origin_url"
  
 -                      if test -e "$sm_path"/.git
 +                      if test -n "$recursive"
                        then
 -                      (
 -                              sanitize_submodule_env
 -                              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
 -                      )
 +                              prefix="$prefix$sm_path/"
 +                              eval cmd_sync
                        fi
 +              )
                fi
        done
  }