Merge branch 'us/printf-not-echo'
[gitweb.git] / builtin / push.c
index 0e50ddbb01342128d9118217118726000bdeaff6..f8dfea41e1ad8b6d888c1a2adc13eee87083491e 100644 (file)
@@ -26,7 +26,6 @@ static struct push_cas_option cas;
 static const char **refspec;
 static int refspec_nr;
 static int refspec_alloc;
-static int default_matching_used;
 
 static void add_refspec(const char *ref)
 {
@@ -59,7 +58,7 @@ static const char *map_refspec(const char *ref,
        }
 
        if (push_default == PUSH_DEFAULT_UPSTREAM &&
-           !prefixcmp(matched->name, "refs/heads/")) {
+           starts_with(matched->name, "refs/heads/")) {
                struct branch *branch = branch_get(matched->name + 11);
                if (branch->merge_nr == 1 && branch->merge[0]->src) {
                        struct strbuf buf = STRBUF_INIT;
@@ -204,9 +203,9 @@ static void setup_push_current(struct remote *remote, struct branch *branch)
 }
 
 static char warn_unspecified_push_default_msg[] =
-N_("push.default is unset; its implicit value is changing in\n"
+N_("push.default is unset; its implicit value has changed 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"
+   "and maintain the traditional behavior, use:\n"
    "\n"
    "  git config --global push.default matching\n"
    "\n"
@@ -217,7 +216,7 @@ N_("push.default is unset; its implicit value is changing in\n"
    "When push.default is set to 'matching', git will push local branches\n"
    "to the remote branches that already exist with the same name.\n"
    "\n"
-   "In Git 2.0, Git will default to the more conservative 'simple'\n"
+   "Since Git 2.0, Git defaults to the more conservative 'simple'\n"
    "behavior, which only pushes the current branch to the corresponding\n"
    "remote branch that 'git pull' uses to update the current branch.\n"
    "\n"
@@ -247,14 +246,14 @@ 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(":");
                break;
 
+       case PUSH_DEFAULT_UNSPECIFIED:
+               warn_unspecified_push_default_configuration();
+               /* fallthru */
+
        case PUSH_DEFAULT_SIMPLE:
                if (triangular)
                        setup_push_current(remote, branch);
@@ -283,12 +282,6 @@ static const char message_advice_pull_before_push[] =
           "'git pull ...') before pushing again.\n"
           "See the 'Note about fast-forwards' in 'git push --help' for details.");
 
-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 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"
           "counterpart. Check out this branch and integrate the remote changes\n"
@@ -317,13 +310,6 @@ static void advise_pull_before_push(void)
        advise(_(message_advice_pull_before_push));
 }
 
-static void advise_use_upstream(void)
-{
-       if (!advice_push_non_ff_default || !advice_push_update_rejected)
-               return;
-       advise(_(message_advice_use_upstream));
-}
-
 static void advise_checkout_pull_push(void)
 {
        if (!advice_push_non_ff_matching || !advice_push_update_rejected)
@@ -385,10 +371,7 @@ static int push_with_options(struct transport *transport, int flags)
        if (reject_reasons & REJECT_NON_FF_HEAD) {
                advise_pull_before_push();
        } else if (reject_reasons & REJECT_NON_FF_OTHER) {
-               if (default_matching_used)
-                       advise_use_upstream();
-               else
-                       advise_checkout_pull_push();
+               advise_checkout_pull_push();
        } else if (reject_reasons & REJECT_ALREADY_EXISTS) {
                advise_ref_already_exists();
        } else if (reject_reasons & REJECT_FETCH_FIRST) {