Skip to content

Commit f2c2c90

Browse files
moygitster
authored andcommitted
push: start warning upcoming default change for push.default
In preparation for flipping the default to the "simple" mode from the "matching" mode that is the historical default, start warning users when they rely on unconfigured "git push" to default to the "matching" mode. Also, advertise for 'simple' where 'current' and 'upstream' are advised. Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f4d80d2 commit f2c2c90

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

builtin/push.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,37 @@ static void setup_push_upstream(struct remote *remote, int simple)
147147
add_refspec(refspec.buf);
148148
}
149149

150+
static char warn_unspecified_push_default_msg[] =
151+
N_("push.default is unset; its implicit value is changing in\n"
152+
"Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
153+
"and maintain the current behavior after the default changes, use:\n"
154+
"\n"
155+
" git config --global push.default matching\n"
156+
"\n"
157+
"To squelch this message and adopt the new behavior now, use:\n"
158+
"\n"
159+
" git config --global push.default simple\n"
160+
"\n"
161+
"See 'git help config' and search for 'push.default' for further information.\n"
162+
"(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode\n"
163+
"'current' instead of 'simple' if you sometimes use older versions of Git)");
164+
165+
static void warn_unspecified_push_default_configuration(void)
166+
{
167+
static int warn_once;
168+
169+
if (warn_once++)
170+
return;
171+
warning("%s\n", _(warn_unspecified_push_default_msg));
172+
}
173+
150174
static void setup_default_push_refspecs(struct remote *remote)
151175
{
152176
switch (push_default) {
153177
default:
154178
case PUSH_DEFAULT_UNSPECIFIED:
155179
default_matching_used = 1;
180+
warn_unspecified_push_default_configuration();
156181
/* fallthru */
157182
case PUSH_DEFAULT_MATCHING:
158183
add_refspec(":");
@@ -186,8 +211,8 @@ static const char message_advice_pull_before_push[] =
186211
static const char message_advice_use_upstream[] =
187212
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
188213
"counterpart. If you did not intend to push that branch, you may want to\n"
189-
"specify branches to push or set the 'push.default' configuration\n"
190-
"variable to 'current' or 'upstream' to push only the current branch.");
214+
"specify branches to push or set the 'push.default' configuration variable\n"
215+
"to 'simple', 'current' or 'upstream' to push only the current branch.");
191216

192217
static const char message_advice_checkout_pull_push[] =
193218
N_("Updates were rejected because a pushed branch tip is behind its remote\n"

t/t5541-http-push.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ test_expect_success 'no empty path components' '
6464

6565
test_expect_success 'clone remote repository' '
6666
rm -rf test_repo_clone &&
67-
git clone $HTTPD_URL/smart/test_repo.git test_repo_clone
67+
git clone $HTTPD_URL/smart/test_repo.git test_repo_clone &&
68+
(
69+
cd test_repo_clone && git config push.default matching
70+
)
6871
'
6972

7073
test_expect_success 'push to remote repository (standard)' '

0 commit comments

Comments
 (0)