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>
Junio C Hamano committed
Jan 4, 2013 at 16:02 UTC
b2ed944af79041b4da151a432064c3b1c1b82fc5
5 files changed
+25
-48
Documentation/config.txt
+4
-10
@@ -142,17 +142,11 @@ advice.*::
142
--
143
pushNonFastForward::
144
Set this variable to 'false' if you want to disable
145
- 'pushNonFFCurrent', 'pushNonFFDefault', and
145
+ 'pushNonFFCurrent', and
146
'pushNonFFMatching' simultaneously.
147
pushNonFFCurrent::
148
Advice shown when linkgit:git-push[1] fails due to a
149
non-fast-forward update to the current branch.
150
- pushNonFFDefault::
151
- Advice to set 'push.default' to 'upstream' or 'current'
152
- when you ran linkgit:git-push[1] and pushed 'matching
153
- refs' by default (i.e. you did not provide an explicit
154
- refspec, and no 'push.default' configuration was set)
155
- and it resulted in a non-fast-forward error.
150
pushNonFFMatching::
151
Advice shown when you ran linkgit:git-push[1] and pushed
152
'matching refs' explicitly (i.e. you used ':', or
@@ -1750,15 +1744,15 @@ push.default::
1744
since locally stalled branches will attempt a non-fast forward push
1745
if other users updated the branch.
1746
+
1753
- This is currently the default, but Git 2.0 will change the default
1754
- to `simple`.
1747
+ This used to be the default, and stale web sites may still say so,
1748
+ but Git 2.0 has changed the default to `simple`.
1749
* `upstream` - push the current branch to its upstream branch.
1750
With this, `git push` will update the same remote ref as the one which
1751
is merged by `git pull`, making `push` and `pull` symmetrical.
1752
See "branch.<name>.merge" for how to configure the upstream branch.
1753
* `simple` - like `upstream`, but refuses to push if the upstream
1754
branch's name is different from the local one. This is the safest
1761
- option and is well-suited for beginners. It will become the default
1755
+ option and is well-suited for beginners. It has become the default
1756
in Git 2.0.
1757
* `current` - push the current branch to a branch of the same name.
1758
--
Documentation/git-push.txt
+14
-11
@@ -36,10 +36,14 @@ OPTIONS[[OPTIONS]]
36
The format of a <refspec> parameter is an optional plus
37
`+`, followed by the source ref <src>, followed
38
by a colon `:`, followed by the destination ref <dst>.
39
- It is used to specify with what <src> object the <dst> ref
40
- in the remote repository is to be updated. If not specified,
39
+ It is used to specify what <src> object the <dst> ref
40
+ in the remote repository is to be updated to. If no
41
+ <refspec> is specified on the command line, and if no
42
+ <refspec> is configured for the <repository>,
43
the behavior of the command is controlled by the `push.default`
42
- configuration variable.
44
+ configuration variable, and if it is unset, the `simple`
45
+ behaviour is used (see lingit:git-config[1] and look
46
+ for `push.default`).
47
+
48
The <src> is often the name of the branch you would want to push, but
49
it can be any arbitrary "SHA-1 expression", such as `master~4` or
@@ -65,14 +69,11 @@ the remote repository.
69
The special refspec `:` (or `+:` to allow non-fast-forward updates)
70
directs git to push "matching" branches: for every branch that exists on
71
the local side, the remote side is updated if a branch of the same name
68
-already exists on the remote side. This is the default operation mode
69
-if no explicit refspec is found (that is neither on the command line
70
-nor in any Push line of the corresponding remotes file---see below) and
71
-no `push.default` configuration variable is set.
72
+already exists on the remote side.
73
74
--all::
74
- Instead of naming each ref to push, specifies that all
75
- refs under `refs/heads/` be pushed.
75
+ Push all branches (i.e. refs under `refs/heads/`); cannot be
76
+ used with other <refspec>.
77
78
--prune::
79
Remove remote branches that don't have a local counterpart. For example
@@ -357,8 +358,10 @@ Examples
358
configured for the current branch).
359
360
`git push origin`::
360
- Without additional configuration, works like
361
- `git push origin :`.
361
+ Without additional configuration, pushes the current branch to
362
+ the configured upstream (`remote.origin.merge` configuration
363
+ variable) if it has the same name as the current branch, and
364
+ errors out without pushing otherwise.
365
+
366
The default behavior of this command when no <refspec> is given can be
367
configured by setting the `push` option of the remote, or the `push.default`
advice.c
-2
@@ -2,7 +2,6 @@
2
3
int advice_push_nonfastforward = 1;
4
int advice_push_non_ff_current = 1;
5
-int advice_push_non_ff_default = 1;
5
int advice_push_non_ff_matching = 1;
6
int advice_status_hints = 1;
7
int advice_commit_before_merge = 1;
@@ -16,7 +15,6 @@ static struct {
15
} advice_config[] = {
16
{ "pushnonfastforward", &advice_push_nonfastforward },
17
{ "pushnonffcurrent", &advice_push_non_ff_current },
19
- { "pushnonffdefault", &advice_push_non_ff_default },
18
{ "pushnonffmatching", &advice_push_non_ff_matching },
19
{ "statushints", &advice_status_hints },
20
{ "commitbeforemerge", &advice_commit_before_merge },
advice.h
-1
@@ -5,7 +5,6 @@
5
6
extern int advice_push_nonfastforward;
7
extern int advice_push_non_ff_current;
8
-extern int advice_push_non_ff_default;
8
extern int advice_push_non_ff_matching;
9
extern int advice_status_hints;
10
extern int advice_commit_before_merge;
builtin/push.c
+7
-24
@@ -24,7 +24,6 @@ static int progress = -1;
24
static const char **refspec;
25
static int refspec_nr;
26
static int refspec_alloc;
27
-static int default_matching_used;
27
28
static void add_refspec(const char *ref)
29
{
@@ -148,9 +147,9 @@ static void setup_push_upstream(struct remote *remote, int simple)
147
}
148
149
static char warn_unspecified_push_default_msg[] =
151
-N_("push.default is unset; its implicit value is changing in\n"
150
+N_("push.default is unset; its implicit value has changed in\n"
151
"Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
153
- "and maintain the current behavior after the default changes, use:\n"
152
+ "and maintain the traditional behavior, use:\n"
153
"\n"
154
" git config --global push.default matching\n"
155
"\n"
@@ -175,14 +174,14 @@ static void setup_default_push_refspecs(struct remote *remote)
174
{
175
switch (push_default) {
176
default:
178
- case PUSH_DEFAULT_UNSPECIFIED:
179
- default_matching_used = 1;
180
- warn_unspecified_push_default_configuration();
181
- /* fallthru */
177
case PUSH_DEFAULT_MATCHING:
178
add_refspec(":");
179
break;
180
181
+ case PUSH_DEFAULT_UNSPECIFIED:
182
+ warn_unspecified_push_default_configuration();
183
+ /* fallthru */
184
+
185
case PUSH_DEFAULT_SIMPLE:
186
setup_push_upstream(remote, 1);
187
break;
@@ -208,12 +207,6 @@ static const char message_advice_pull_before_push[] =
207
"before pushing again.\n"
208
"See the 'Note about fast-forwards' in 'git push --help' for details.");
209
211
-static const char message_advice_use_upstream[] =
212
- N_("Updates were rejected because a pushed branch tip is behind its remote\n"
213
- "counterpart. If you did not intend to push that branch, you may want to\n"
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.");
216
-
210
static const char message_advice_checkout_pull_push[] =
211
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
212
"counterpart. Check out this branch and merge the remote changes\n"
@@ -227,13 +220,6 @@ static void advise_pull_before_push(void)
220
advise(_(message_advice_pull_before_push));
221
}
222
230
-static void advise_use_upstream(void)
231
-{
232
- if (!advice_push_non_ff_default || !advice_push_nonfastforward)
233
- return;
234
- advise(_(message_advice_use_upstream));
235
-}
236
-
223
static void advise_checkout_pull_push(void)
224
{
225
if (!advice_push_non_ff_matching || !advice_push_nonfastforward)
@@ -272,10 +258,7 @@ static int push_with_options(struct transport *transport, int flags)
258
advise_pull_before_push();
259
break;
260
case NON_FF_OTHER:
275
- if (default_matching_used)
276
- advise_use_upstream();
277
- else
278
- advise_checkout_pull_push();
261
+ advise_checkout_pull_push();
262
break;
263
}
264