Merge branch 'mm/push-default-switch-warning'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2012 18:54:04 +0000 (11:54 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2012 18:54:04 +0000 (11:54 -0700)
In the next major release, we will switch "git push [$there]" that
does not say what to push from the traditional "matching" to the
updated "simple" semantics, that pushes the current branch to the
branch with the same name only when the current branch is set to
integrate with that remote branch (all other cases will error out).

* mm/push-default-switch-warning:
push: start warning upcoming default change for push.default

1  2 
builtin/push.c
t/t5541-http-push.sh
diff --combined builtin/push.c
index fdfcc6c71607a7412666b7cc647db98e1b85c8c1,9a0a03562969afaf1a10d0509cfc1d74313ca7e1..9ed558485babb4194729a97320e62402af8481bd
@@@ -147,12 -147,37 +147,37 @@@ static void setup_push_upstream(struct 
        add_refspec(refspec.buf);
  }
  
+ static char warn_unspecified_push_default_msg[] =
+ N_("push.default is unset; its implicit value is changing in\n"
+    "Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
+    "and maintain the current behavior after the default changes, use:\n"
+    "\n"
+    "  git config --global push.default matching\n"
+    "\n"
+    "To squelch this message and adopt the new behavior now, use:\n"
+    "\n"
+    "  git config --global push.default simple\n"
+    "\n"
+    "See 'git help config' and search for 'push.default' for further information.\n"
+    "(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode\n"
+    "'current' instead of 'simple' if you sometimes use older versions of Git)");
+ static void warn_unspecified_push_default_configuration(void)
+ {
+       static int warn_once;
+       if (warn_once++)
+               return;
+       warning("%s\n", _(warn_unspecified_push_default_msg));
+ }
  static void setup_default_push_refspecs(struct remote *remote)
  {
        switch (push_default) {
        default:
        case PUSH_DEFAULT_UNSPECIFIED:
                default_matching_used = 1;
+               warn_unspecified_push_default_configuration();
                /* fallthru */
        case PUSH_DEFAULT_MATCHING:
                add_refspec(":");
@@@ -186,8 -211,8 +211,8 @@@ static const char message_advice_pull_b
  static const char message_advice_use_upstream[] =
        N_("Updates were rejected because a pushed branch tip is behind its remote\n"
           "counterpart. If you did not intend to push that branch, you may want to\n"
-          "specify branches to push or set the 'push.default' configuration\n"
-          "variable to 'current' or 'upstream' to push only the current branch.");
+          "specify branches to push or set the 'push.default' configuration variable\n"
+          "to 'simple', 'current' or 'upstream' to push only the current branch.");
  
  static const char message_advice_checkout_pull_push[] =
        N_("Updates were rejected because a pushed branch tip is behind its remote\n"
@@@ -327,21 -352,13 +352,21 @@@ static int option_parse_recurse_submodu
                                   const char *arg, int unset)
  {
        int *flags = opt->value;
 +
 +      if (*flags & (TRANSPORT_RECURSE_SUBMODULES_CHECK |
 +                    TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND))
 +              die("%s can only be used once.", opt->long_name);
 +
        if (arg) {
                if (!strcmp(arg, "check"))
                        *flags |= TRANSPORT_RECURSE_SUBMODULES_CHECK;
 +              else if (!strcmp(arg, "on-demand"))
 +                      *flags |= TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND;
                else
                        die("bad %s argument: %s", opt->long_name, arg);
        } else
 -              die("option %s needs an argument (check)", opt->long_name);
 +              die("option %s needs an argument (check|on-demand)",
 +                              opt->long_name);
  
        return 0;
  }
diff --combined t/t5541-http-push.sh
index 312e484090d1ceb392399768f2229ae553182fe7,07fa199b142028144a0443b21fcf0a721570d897..624633aced58169ac1b821fb44d3ad5f25996894
@@@ -64,7 -64,10 +64,10 @@@ test_expect_success 'no empty path comp
  
  test_expect_success 'clone remote repository' '
        rm -rf test_repo_clone &&
-       git clone $HTTPD_URL/smart/test_repo.git test_repo_clone
+       git clone $HTTPD_URL/smart/test_repo.git test_repo_clone &&
+       (
+               cd test_repo_clone && git config push.default matching
+       )
  '
  
  test_expect_success 'push to remote repository (standard)' '
@@@ -216,36 -219,13 +219,36 @@@ test_expect_success 'push --mirror to r
        git push --mirror "$HTTPD_URL"/smart/alternates-mirror.git
  '
  
 -test_expect_success TTY 'quiet push' '
 +test_expect_success TTY 'push shows progress when stderr is a tty' '
 +      cd "$ROOT_PATH"/test_repo_clone &&
 +      test_commit noisy &&
 +      test_terminal git push >output 2>&1 &&
 +      grep "^Writing objects" output
 +'
 +
 +test_expect_success TTY 'push --quiet silences status and progress' '
        cd "$ROOT_PATH"/test_repo_clone &&
        test_commit quiet &&
 -      test_terminal git push --quiet --no-progress 2>&1 | tee output &&
 +      test_terminal git push --quiet >output 2>&1 &&
        test_cmp /dev/null output
  '
  
 +test_expect_success TTY 'push --no-progress silences progress but not status' '
 +      cd "$ROOT_PATH"/test_repo_clone &&
 +      test_commit no-progress &&
 +      test_terminal git push --no-progress >output 2>&1 &&
 +      grep "^To http" output &&
 +      ! grep "^Writing objects"
 +'
 +
 +test_expect_success 'push --progress shows progress to non-tty' '
 +      cd "$ROOT_PATH"/test_repo_clone &&
 +      test_commit progress &&
 +      git push --progress >output 2>&1 &&
 +      grep "^To http" output &&
 +      grep "^Writing objects" output
 +'
 +
  test_expect_success 'http push gives sane defaults to reflog' '
        cd "$ROOT_PATH"/test_repo_clone &&
        test_commit reflog-test &&