Skip to content

Commit 009055f

Browse files
committed
Merge branch 'jc/push-2.0-default-to-simple'
Finally update the "git push" default behaviour to "simple".
2 parents 6ab4ae2 + b2ed944 commit 009055f

File tree

5 files changed

+17
-41
lines changed

5 files changed

+17
-41
lines changed

Documentation/config.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,13 @@ advice.*::
142142
--
143143
pushUpdateRejected::
144144
Set this variable to 'false' if you want to disable
145-
'pushNonFFCurrent', 'pushNonFFDefault',
145+
'pushNonFFCurrent',
146146
'pushNonFFMatching', 'pushAlreadyExists',
147147
'pushFetchFirst', and 'pushNeedsForce'
148148
simultaneously.
149149
pushNonFFCurrent::
150150
Advice shown when linkgit:git-push[1] fails due to a
151151
non-fast-forward update to the current branch.
152-
pushNonFFDefault::
153-
Advice to set 'push.default' to 'upstream' or 'current'
154-
when you ran linkgit:git-push[1] and pushed 'matching
155-
refs' by default (i.e. you did not provide an explicit
156-
refspec, and no 'push.default' configuration was set)
157-
and it resulted in a non-fast-forward error.
158152
pushNonFFMatching::
159153
Advice shown when you ran linkgit:git-push[1] and pushed
160154
'matching refs' explicitly (i.e. you used ':', or
@@ -1980,7 +1974,7 @@ When pushing to a remote that is different from the remote you normally
19801974
pull from, work as `current`. This is the safest option and is suited
19811975
for beginners.
19821976
+
1983-
This mode will become the default in Git 2.0.
1977+
This mode has become the default in Git 2.0.
19841978

19851979
* `matching` - push all branches having the same name on both ends.
19861980
This makes the repository you are pushing to remember the set of
@@ -1999,8 +1993,8 @@ suitable for pushing into a shared central repository, as other
19991993
people may add new branches there, or update the tip of existing
20001994
branches outside your control.
20011995
+
2002-
This is currently the default, but Git 2.0 will change the default
2003-
to `simple`.
1996+
This used to be the default, but not since Git 2.0 (`simple` is the
1997+
new default).
20041998

20051999
--
20062000

Documentation/git-push.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ the local side, the remote side is updated if a branch of the same name
8383
already exists on the remote side.
8484

8585
--all::
86-
Instead of naming each ref to push, specifies that all
87-
refs under `refs/heads/` be pushed.
86+
Push all branches (i.e. refs under `refs/heads/`); cannot be
87+
used with other <refspec>.
8888

8989
--prune::
9090
Remove remote branches that don't have a local counterpart. For example
@@ -442,8 +442,10 @@ Examples
442442
configured for the current branch).
443443

444444
`git push origin`::
445-
Without additional configuration, works like
446-
`git push origin :`.
445+
Without additional configuration, pushes the current branch to
446+
the configured upstream (`remote.origin.merge` configuration
447+
variable) if it has the same name as the current branch, and
448+
errors out without pushing otherwise.
447449
+
448450
The default behavior of this command when no <refspec> is given can be
449451
configured by setting the `push` option of the remote, or the `push.default`

advice.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
int advice_push_update_rejected = 1;
44
int advice_push_non_ff_current = 1;
5-
int advice_push_non_ff_default = 1;
65
int advice_push_non_ff_matching = 1;
76
int advice_push_already_exists = 1;
87
int advice_push_fetch_first = 1;
@@ -23,7 +22,6 @@ static struct {
2322
} advice_config[] = {
2423
{ "pushupdaterejected", &advice_push_update_rejected },
2524
{ "pushnonffcurrent", &advice_push_non_ff_current },
26-
{ "pushnonffdefault", &advice_push_non_ff_default },
2725
{ "pushnonffmatching", &advice_push_non_ff_matching },
2826
{ "pushalreadyexists", &advice_push_already_exists },
2927
{ "pushfetchfirst", &advice_push_fetch_first },

advice.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
extern int advice_push_update_rejected;
77
extern int advice_push_non_ff_current;
8-
extern int advice_push_non_ff_default;
98
extern int advice_push_non_ff_matching;
109
extern int advice_push_already_exists;
1110
extern int advice_push_fetch_first;

builtin/push.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ static struct push_cas_option cas;
2626
static const char **refspec;
2727
static int refspec_nr;
2828
static int refspec_alloc;
29-
static int default_matching_used;
3029

3130
static void add_refspec(const char *ref)
3231
{
@@ -204,9 +203,9 @@ static void setup_push_current(struct remote *remote, struct branch *branch)
204203
}
205204

206205
static char warn_unspecified_push_default_msg[] =
207-
N_("push.default is unset; its implicit value is changing in\n"
206+
N_("push.default is unset; its implicit value has changed in\n"
208207
"Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
209-
"and maintain the current behavior after the default changes, use:\n"
208+
"and maintain the traditional behavior, use:\n"
210209
"\n"
211210
" git config --global push.default matching\n"
212211
"\n"
@@ -247,14 +246,14 @@ static void setup_default_push_refspecs(struct remote *remote)
247246

248247
switch (push_default) {
249248
default:
250-
case PUSH_DEFAULT_UNSPECIFIED:
251-
default_matching_used = 1;
252-
warn_unspecified_push_default_configuration();
253-
/* fallthru */
254249
case PUSH_DEFAULT_MATCHING:
255250
add_refspec(":");
256251
break;
257252

253+
case PUSH_DEFAULT_UNSPECIFIED:
254+
warn_unspecified_push_default_configuration();
255+
/* fallthru */
256+
258257
case PUSH_DEFAULT_SIMPLE:
259258
if (triangular)
260259
setup_push_current(remote, branch);
@@ -283,12 +282,6 @@ static const char message_advice_pull_before_push[] =
283282
"'git pull ...') before pushing again.\n"
284283
"See the 'Note about fast-forwards' in 'git push --help' for details.");
285284

286-
static const char message_advice_use_upstream[] =
287-
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
288-
"counterpart. If you did not intend to push that branch, you may want to\n"
289-
"specify branches to push or set the 'push.default' configuration variable\n"
290-
"to 'simple', 'current' or 'upstream' to push only the current branch.");
291-
292285
static const char message_advice_checkout_pull_push[] =
293286
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
294287
"counterpart. Check out this branch and integrate the remote changes\n"
@@ -317,13 +310,6 @@ static void advise_pull_before_push(void)
317310
advise(_(message_advice_pull_before_push));
318311
}
319312

320-
static void advise_use_upstream(void)
321-
{
322-
if (!advice_push_non_ff_default || !advice_push_update_rejected)
323-
return;
324-
advise(_(message_advice_use_upstream));
325-
}
326-
327313
static void advise_checkout_pull_push(void)
328314
{
329315
if (!advice_push_non_ff_matching || !advice_push_update_rejected)
@@ -385,10 +371,7 @@ static int push_with_options(struct transport *transport, int flags)
385371
if (reject_reasons & REJECT_NON_FF_HEAD) {
386372
advise_pull_before_push();
387373
} else if (reject_reasons & REJECT_NON_FF_OTHER) {
388-
if (default_matching_used)
389-
advise_use_upstream();
390-
else
391-
advise_checkout_pull_push();
374+
advise_checkout_pull_push();
392375
} else if (reject_reasons & REJECT_ALREADY_EXISTS) {
393376
advise_ref_already_exists();
394377
} else if (reject_reasons & REJECT_FETCH_FIRST) {

0 commit comments

Comments
 (0)