Skip to content

Commit 11037ee

Browse files
committed
push: switch default from "matching" to "simple"
We promised to change the behaviour of lazy "git push [there]" that does not say what to push on the command line from "matching" to "simple" in Git 2.0. This finally flips that bit. Helped-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c13a5fe commit 11037ee

File tree

5 files changed

+18
-42
lines changed

5 files changed

+18
-42
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
@@ -1929,7 +1923,7 @@ When pushing to a remote that is different from the remote you normally
19291923
pull from, work as `current`. This is the safest option and is suited
19301924
for beginners.
19311925
+
1932-
This mode will become the default in Git 2.0.
1926+
This mode has become the default in Git 2.0.
19331927

19341928
* `matching` - push all branches having the same name on both ends.
19351929
This makes the repository you are pushing to remember the set of
@@ -1948,8 +1942,8 @@ suitable for pushing into a shared central repository, as other
19481942
people may add new branches there, or update the tip of existing
19491943
branches outside your control.
19501944
+
1951-
This is currently the default, but Git 2.0 will change the default
1952-
to `simple`.
1945+
This used to be the default, but not since Git 2.0 (`simple` is the
1946+
new default).
19531947

19541948
--
19551949

Documentation/git-push.txt

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

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

8484
--prune::
8585
Remove remote branches that don't have a local counterpart. For example
@@ -437,8 +437,10 @@ Examples
437437
configured for the current branch).
438438

439439
`git push origin`::
440-
Without additional configuration, works like
441-
`git push origin :`.
440+
Without additional configuration, pushes the current branch to
441+
the configured upstream (`remote.origin.merge` configuration
442+
variable) if it has the same name as the current branch, and
443+
errors out without pushing otherwise.
442444
+
443445
The default behavior of this command when no <refspec> is given can be
444446
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: 8 additions & 25 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
{
@@ -164,9 +163,9 @@ static void setup_push_current(struct remote *remote, struct branch *branch)
164163
}
165164

166165
static char warn_unspecified_push_default_msg[] =
167-
N_("push.default is unset; its implicit value is changing in\n"
166+
N_("push.default is unset; its implicit value has changed in\n"
168167
"Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
169-
"and maintain the current behavior after the default changes, use:\n"
168+
"and maintain the traditional behavior, use:\n"
170169
"\n"
171170
" git config --global push.default matching\n"
172171
"\n"
@@ -177,7 +176,7 @@ N_("push.default is unset; its implicit value is changing in\n"
177176
"When push.default is set to 'matching', git will push local branches\n"
178177
"to the remote branches that already exist with the same name.\n"
179178
"\n"
180-
"In Git 2.0, Git will default to the more conservative 'simple'\n"
179+
"Since Git 2.0, Git defaults to the more conservative 'simple'\n"
181180
"behavior, which only pushes the current branch to the corresponding\n"
182181
"remote branch that 'git pull' uses to update the current branch.\n"
183182
"\n"
@@ -207,14 +206,14 @@ static void setup_default_push_refspecs(struct remote *remote)
207206

208207
switch (push_default) {
209208
default:
210-
case PUSH_DEFAULT_UNSPECIFIED:
211-
default_matching_used = 1;
212-
warn_unspecified_push_default_configuration();
213-
/* fallthru */
214209
case PUSH_DEFAULT_MATCHING:
215210
add_refspec(":");
216211
break;
217212

213+
case PUSH_DEFAULT_UNSPECIFIED:
214+
warn_unspecified_push_default_configuration();
215+
/* fallthru */
216+
218217
case PUSH_DEFAULT_SIMPLE:
219218
if (triangular)
220219
setup_push_current(remote, branch);
@@ -243,12 +242,6 @@ static const char message_advice_pull_before_push[] =
243242
"'git pull ...') before pushing again.\n"
244243
"See the 'Note about fast-forwards' in 'git push --help' for details.");
245244

246-
static const char message_advice_use_upstream[] =
247-
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
248-
"counterpart. If you did not intend to push that branch, you may want to\n"
249-
"specify branches to push or set the 'push.default' configuration variable\n"
250-
"to 'simple', 'current' or 'upstream' to push only the current branch.");
251-
252245
static const char message_advice_checkout_pull_push[] =
253246
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
254247
"counterpart. Check out this branch and integrate the remote changes\n"
@@ -277,13 +270,6 @@ static void advise_pull_before_push(void)
277270
advise(_(message_advice_pull_before_push));
278271
}
279272

280-
static void advise_use_upstream(void)
281-
{
282-
if (!advice_push_non_ff_default || !advice_push_update_rejected)
283-
return;
284-
advise(_(message_advice_use_upstream));
285-
}
286-
287273
static void advise_checkout_pull_push(void)
288274
{
289275
if (!advice_push_non_ff_matching || !advice_push_update_rejected)
@@ -345,10 +331,7 @@ static int push_with_options(struct transport *transport, int flags)
345331
if (reject_reasons & REJECT_NON_FF_HEAD) {
346332
advise_pull_before_push();
347333
} else if (reject_reasons & REJECT_NON_FF_OTHER) {
348-
if (default_matching_used)
349-
advise_use_upstream();
350-
else
351-
advise_checkout_pull_push();
334+
advise_checkout_pull_push();
352335
} else if (reject_reasons & REJECT_ALREADY_EXISTS) {
353336
advise_ref_already_exists();
354337
} else if (reject_reasons & REJECT_FETCH_FIRST) {

0 commit comments

Comments
 (0)