Skip to content

Commit 5293b54

Browse files
moygitster
authored andcommitted
push: start warning upcoming default change for push.default
In preparation for flipping the default to the "upstream" 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. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 42e52e3 commit 5293b54

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

builtin/push.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,35 @@ static void setup_push_upstream(struct remote *remote)
9191
add_refspec(refspec.buf);
9292
}
9393

94+
static char warn_unspecified_push_default_msg[] =
95+
N_("push.default is unset; its implicit value is changing in\n"
96+
"Git 2.0 from 'matching' to 'upstream'. To squelch this message\n"
97+
"and maintain the current behavior after the default changes, use:\n"
98+
"\n"
99+
" git config --global push.default matching\n"
100+
"\n"
101+
"To squelch this message and adopt the new behavior now, use:\n"
102+
"\n"
103+
" git config --global push.default upstream\n"
104+
"\n"
105+
"See 'git help config' and search for 'push.default' for further information.");
106+
107+
static void warn_unspecified_push_default_configuration(void)
108+
{
109+
static int warn_once;
110+
111+
if (warn_once++)
112+
return;
113+
warning("%s\n", _(warn_unspecified_push_default_msg));
114+
}
115+
94116
static void setup_default_push_refspecs(struct remote *remote)
95117
{
96118
switch (push_default) {
97119
default:
120+
case PUSH_DEFAULT_UNSPECIFIED:
121+
warn_unspecified_push_default_configuration();
122+
/* fallthru */
98123
case PUSH_DEFAULT_MATCHING:
99124
add_refspec(":");
100125
break;

cache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ enum push_default_type {
625625
PUSH_DEFAULT_NOTHING = 0,
626626
PUSH_DEFAULT_MATCHING,
627627
PUSH_DEFAULT_UPSTREAM,
628-
PUSH_DEFAULT_CURRENT
628+
PUSH_DEFAULT_CURRENT,
629+
PUSH_DEFAULT_UNSPECIFIED
629630
};
630631

631632
extern enum branch_track git_branch_track;

environment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
5252
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
5353
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
5454
enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
55-
enum push_default_type push_default = PUSH_DEFAULT_MATCHING;
55+
enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
5656
#ifndef OBJECT_CREATION_MODE
5757
#define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
5858
#endif

0 commit comments

Comments
 (0)