Merge branch 'jl/submodule-update-retire-orig-flags'
authorJunio C Hamano <gitster@pobox.com>
Thu, 5 Dec 2013 21:00:20 +0000 (13:00 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Dec 2013 21:00:20 +0000 (13:00 -0800)
Code clean-up.

* jl/submodule-update-retire-orig-flags:
submodule update: remove unnecessary orig_flags variable

1  2 
git-submodule.sh
t/t7406-submodule-update.sh
diff --combined git-submodule.sh
index ed02f032140e0e93fd920f591f41bc328a071833,74cbc53b53cef2e482726e82d547f8425cd073da..2677f2e8b3c57dc5c1a632e5705b26f74cbd7137
@@@ -156,7 -156,7 +156,7 @@@ module_list(
                git ls-files -z --error-unmatch --stage -- "$@" ||
                echo "unmatched pathspec exists"
        ) |
 -      perl -e '
 +      @@PERL@@ -e '
        my %unmerged = ();
        my ($null_sha1) = ("0" x 40);
        my @out = ();
@@@ -545,12 -545,7 +545,12 @@@ cmd_foreach(
                                sm_path=$(relative_path "$sm_path") &&
                                # we make $path available to scripts ...
                                path=$sm_path &&
 -                              eval "$@" &&
 +                              if test $# -eq 1
 +                              then
 +                                      eval "$1"
 +                              else
 +                                      "$@"
 +                              fi &&
                                if test -n "$recursive"
                                then
                                        cmd_foreach "--recursive" "$@"
@@@ -617,21 -612,11 +617,21 @@@ cmd_init(
                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 "$(eval_gettext "Failed to register update mode for submodule path '\$displaypath'")"
 +              if upd="$(git config -f .gitmodules submodule."$name".update)" &&
 +                 test -n "$upd" &&
 +                 test -z "$(git config submodule."$name".update)"
 +              then
 +                      case "$upd" in
 +                      rebase | merge | none)
 +                              ;; # known modes of updating
 +                      *)
 +                              echo >&2 "warning: unknown update mode '$upd' suggested for submodule '$name'"
 +                              upd=none
 +                              ;;
 +                      esac
 +                      git config submodule."$name".update "$upd" ||
 +                      die "$(eval_gettext "Failed to register update mode for submodule path '\$displaypath'")"
 +              fi
        done
  }
  
@@@ -721,7 -706,6 +721,6 @@@ cmd_deinit(
  cmd_update()
  {
        # parse $args after "submodule ... update".
-       orig_flags=
        while test $# -ne 0
        do
                case "$1" in
                --reference)
                        case "$2" in '') usage ;; esac
                        reference="--reference=$2"
-                       orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")"
                        shift
                        ;;
                --reference=*)
                        break
                        ;;
                esac
-               orig_flags="$orig_flags $(git rev-parse --sq-quote "$1")"
                shift
        done
  
@@@ -924,7 -906,7 +921,7 @@@ Maybe you want to use 'update --init'?"
                                prefix="$prefix$sm_path/"
                                clear_local_git_env
                                cd "$sm_path" &&
-                               eval cmd_update "$orig_flags"
+                               eval cmd_update
                        )
                        res=$?
                        if test $res -gt 0
index 0825a928dfa2a340f6fce6e2313324bd5d63ea7f,2d9db8e8b7da2c876d65a03811dbb42ea78c2e35..0246e80b1af98fe213b06beb8de0a9fec464b9f2
@@@ -323,21 -323,6 +323,21 @@@ test_expect_success 'submodule update 
        )
  '
  
 +test_expect_success 'submodule init does not copy command into .git/config' '
 +      (cd super &&
 +       H=$(git ls-files -s submodule | cut -d" " -f2) &&
 +       mkdir submodule1 &&
 +       git update-index --add --cacheinfo 160000 $H submodule1 &&
 +       git config -f .gitmodules submodule.submodule1.path submodule1 &&
 +       git config -f .gitmodules submodule.submodule1.url ../submodule &&
 +       git config -f .gitmodules submodule.submodule1.update !false &&
 +       git submodule init submodule1 &&
 +       echo "none" >expect &&
 +       git config submodule.submodule1.update >actual &&
 +       test_cmp expect actual
 +      )
 +'
 +
  test_expect_success 'submodule init picks up rebase' '
        (cd super &&
         git config -f .gitmodules submodule.rebasing.update rebase &&
@@@ -762,6 -747,17 +762,17 @@@ test_expect_success 'submodule update c
         (cd submodule &&
          test 1 = $(git log --oneline | wc -l)
         )
+ )
+ '
+ test_expect_success 'submodule update --recursive drops module name before recursing' '
+       (cd super2 &&
+        (cd deeper/submodule/subsubmodule &&
+         git checkout HEAD^
+        ) &&
+        git submodule update --recursive deeper/submodule >actual &&
+        test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked out" actual
        )
  '
  test_done