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>
This commit is contained in:
parent
ac47a22a7a
commit
b2ed944af7
@ -142,17 +142,11 @@ advice.*::
|
|||||||
--
|
--
|
||||||
pushNonFastForward::
|
pushNonFastForward::
|
||||||
Set this variable to 'false' if you want to disable
|
Set this variable to 'false' if you want to disable
|
||||||
'pushNonFFCurrent', 'pushNonFFDefault', and
|
'pushNonFFCurrent', and
|
||||||
'pushNonFFMatching' simultaneously.
|
'pushNonFFMatching' simultaneously.
|
||||||
pushNonFFCurrent::
|
pushNonFFCurrent::
|
||||||
Advice shown when linkgit:git-push[1] fails due to a
|
Advice shown when linkgit:git-push[1] fails due to a
|
||||||
non-fast-forward update to the current branch.
|
non-fast-forward update to the current branch.
|
||||||
pushNonFFDefault::
|
|
||||||
Advice to set 'push.default' to 'upstream' or 'current'
|
|
||||||
when you ran linkgit:git-push[1] and pushed 'matching
|
|
||||||
refs' by default (i.e. you did not provide an explicit
|
|
||||||
refspec, and no 'push.default' configuration was set)
|
|
||||||
and it resulted in a non-fast-forward error.
|
|
||||||
pushNonFFMatching::
|
pushNonFFMatching::
|
||||||
Advice shown when you ran linkgit:git-push[1] and pushed
|
Advice shown when you ran linkgit:git-push[1] and pushed
|
||||||
'matching refs' explicitly (i.e. you used ':', or
|
'matching refs' explicitly (i.e. you used ':', or
|
||||||
@ -1750,15 +1744,15 @@ push.default::
|
|||||||
since locally stalled branches will attempt a non-fast forward push
|
since locally stalled branches will attempt a non-fast forward push
|
||||||
if other users updated the branch.
|
if other users updated the branch.
|
||||||
+
|
+
|
||||||
This is currently the default, but Git 2.0 will change the default
|
This used to be the default, and stale web sites may still say so,
|
||||||
to `simple`.
|
but Git 2.0 has changed the default to `simple`.
|
||||||
* `upstream` - push the current branch to its upstream branch.
|
* `upstream` - push the current branch to its upstream branch.
|
||||||
With this, `git push` will update the same remote ref as the one which
|
With this, `git push` will update the same remote ref as the one which
|
||||||
is merged by `git pull`, making `push` and `pull` symmetrical.
|
is merged by `git pull`, making `push` and `pull` symmetrical.
|
||||||
See "branch.<name>.merge" for how to configure the upstream branch.
|
See "branch.<name>.merge" for how to configure the upstream branch.
|
||||||
* `simple` - like `upstream`, but refuses to push if the upstream
|
* `simple` - like `upstream`, but refuses to push if the upstream
|
||||||
branch's name is different from the local one. This is the safest
|
branch's name is different from the local one. This is the safest
|
||||||
option and is well-suited for beginners. It will become the default
|
option and is well-suited for beginners. It has become the default
|
||||||
in Git 2.0.
|
in Git 2.0.
|
||||||
* `current` - push the current branch to a branch of the same name.
|
* `current` - push the current branch to a branch of the same name.
|
||||||
--
|
--
|
||||||
|
@ -36,10 +36,14 @@ OPTIONS[[OPTIONS]]
|
|||||||
The format of a <refspec> parameter is an optional plus
|
The format of a <refspec> parameter is an optional plus
|
||||||
`+`, followed by the source ref <src>, followed
|
`+`, followed by the source ref <src>, followed
|
||||||
by a colon `:`, followed by the destination ref <dst>.
|
by a colon `:`, followed by the destination ref <dst>.
|
||||||
It is used to specify with what <src> object the <dst> ref
|
It is used to specify what <src> object the <dst> ref
|
||||||
in the remote repository is to be updated. If not specified,
|
in the remote repository is to be updated to. If no
|
||||||
|
<refspec> is specified on the command line, and if no
|
||||||
|
<refspec> is configured for the <repository>,
|
||||||
the behavior of the command is controlled by the `push.default`
|
the behavior of the command is controlled by the `push.default`
|
||||||
configuration variable.
|
configuration variable, and if it is unset, the `simple`
|
||||||
|
behaviour is used (see lingit:git-config[1] and look
|
||||||
|
for `push.default`).
|
||||||
+
|
+
|
||||||
The <src> is often the name of the branch you would want to push, but
|
The <src> is often the name of the branch you would want to push, but
|
||||||
it can be any arbitrary "SHA-1 expression", such as `master~4` or
|
it can be any arbitrary "SHA-1 expression", such as `master~4` or
|
||||||
@ -65,14 +69,11 @@ the remote repository.
|
|||||||
The special refspec `:` (or `+:` to allow non-fast-forward updates)
|
The special refspec `:` (or `+:` to allow non-fast-forward updates)
|
||||||
directs git to push "matching" branches: for every branch that exists on
|
directs git to push "matching" branches: for every branch that exists on
|
||||||
the local side, the remote side is updated if a branch of the same name
|
the local side, the remote side is updated if a branch of the same name
|
||||||
already exists on the remote side. This is the default operation mode
|
already exists on the remote side.
|
||||||
if no explicit refspec is found (that is neither on the command line
|
|
||||||
nor in any Push line of the corresponding remotes file---see below) and
|
|
||||||
no `push.default` configuration variable is set.
|
|
||||||
|
|
||||||
--all::
|
--all::
|
||||||
Instead of naming each ref to push, specifies that all
|
Push all branches (i.e. refs under `refs/heads/`); cannot be
|
||||||
refs under `refs/heads/` be pushed.
|
used with other <refspec>.
|
||||||
|
|
||||||
--prune::
|
--prune::
|
||||||
Remove remote branches that don't have a local counterpart. For example
|
Remove remote branches that don't have a local counterpart. For example
|
||||||
@ -357,8 +358,10 @@ Examples
|
|||||||
configured for the current branch).
|
configured for the current branch).
|
||||||
|
|
||||||
`git push origin`::
|
`git push origin`::
|
||||||
Without additional configuration, works like
|
Without additional configuration, pushes the current branch to
|
||||||
`git push origin :`.
|
the configured upstream (`remote.origin.merge` configuration
|
||||||
|
variable) if it has the same name as the current branch, and
|
||||||
|
errors out without pushing otherwise.
|
||||||
+
|
+
|
||||||
The default behavior of this command when no <refspec> is given can be
|
The default behavior of this command when no <refspec> is given can be
|
||||||
configured by setting the `push` option of the remote, or the `push.default`
|
configured by setting the `push` option of the remote, or the `push.default`
|
||||||
|
2
advice.c
2
advice.c
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
int advice_push_nonfastforward = 1;
|
int advice_push_nonfastforward = 1;
|
||||||
int advice_push_non_ff_current = 1;
|
int advice_push_non_ff_current = 1;
|
||||||
int advice_push_non_ff_default = 1;
|
|
||||||
int advice_push_non_ff_matching = 1;
|
int advice_push_non_ff_matching = 1;
|
||||||
int advice_status_hints = 1;
|
int advice_status_hints = 1;
|
||||||
int advice_commit_before_merge = 1;
|
int advice_commit_before_merge = 1;
|
||||||
@ -16,7 +15,6 @@ static struct {
|
|||||||
} advice_config[] = {
|
} advice_config[] = {
|
||||||
{ "pushnonfastforward", &advice_push_nonfastforward },
|
{ "pushnonfastforward", &advice_push_nonfastforward },
|
||||||
{ "pushnonffcurrent", &advice_push_non_ff_current },
|
{ "pushnonffcurrent", &advice_push_non_ff_current },
|
||||||
{ "pushnonffdefault", &advice_push_non_ff_default },
|
|
||||||
{ "pushnonffmatching", &advice_push_non_ff_matching },
|
{ "pushnonffmatching", &advice_push_non_ff_matching },
|
||||||
{ "statushints", &advice_status_hints },
|
{ "statushints", &advice_status_hints },
|
||||||
{ "commitbeforemerge", &advice_commit_before_merge },
|
{ "commitbeforemerge", &advice_commit_before_merge },
|
||||||
|
1
advice.h
1
advice.h
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
extern int advice_push_nonfastforward;
|
extern int advice_push_nonfastforward;
|
||||||
extern int advice_push_non_ff_current;
|
extern int advice_push_non_ff_current;
|
||||||
extern int advice_push_non_ff_default;
|
|
||||||
extern int advice_push_non_ff_matching;
|
extern int advice_push_non_ff_matching;
|
||||||
extern int advice_status_hints;
|
extern int advice_status_hints;
|
||||||
extern int advice_commit_before_merge;
|
extern int advice_commit_before_merge;
|
||||||
|
@ -24,7 +24,6 @@ static int progress = -1;
|
|||||||
static const char **refspec;
|
static const char **refspec;
|
||||||
static int refspec_nr;
|
static int refspec_nr;
|
||||||
static int refspec_alloc;
|
static int refspec_alloc;
|
||||||
static int default_matching_used;
|
|
||||||
|
|
||||||
static void add_refspec(const char *ref)
|
static void add_refspec(const char *ref)
|
||||||
{
|
{
|
||||||
@ -148,9 +147,9 @@ static void setup_push_upstream(struct remote *remote, int simple)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char warn_unspecified_push_default_msg[] =
|
static char warn_unspecified_push_default_msg[] =
|
||||||
N_("push.default is unset; its implicit value is changing in\n"
|
N_("push.default is unset; its implicit value has changed in\n"
|
||||||
"Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
|
"Git 2.0 from 'matching' to 'simple'. To squelch this message\n"
|
||||||
"and maintain the current behavior after the default changes, use:\n"
|
"and maintain the traditional behavior, use:\n"
|
||||||
"\n"
|
"\n"
|
||||||
" git config --global push.default matching\n"
|
" git config --global push.default matching\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -175,14 +174,14 @@ static void setup_default_push_refspecs(struct remote *remote)
|
|||||||
{
|
{
|
||||||
switch (push_default) {
|
switch (push_default) {
|
||||||
default:
|
default:
|
||||||
case PUSH_DEFAULT_UNSPECIFIED:
|
|
||||||
default_matching_used = 1;
|
|
||||||
warn_unspecified_push_default_configuration();
|
|
||||||
/* fallthru */
|
|
||||||
case PUSH_DEFAULT_MATCHING:
|
case PUSH_DEFAULT_MATCHING:
|
||||||
add_refspec(":");
|
add_refspec(":");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PUSH_DEFAULT_UNSPECIFIED:
|
||||||
|
warn_unspecified_push_default_configuration();
|
||||||
|
/* fallthru */
|
||||||
|
|
||||||
case PUSH_DEFAULT_SIMPLE:
|
case PUSH_DEFAULT_SIMPLE:
|
||||||
setup_push_upstream(remote, 1);
|
setup_push_upstream(remote, 1);
|
||||||
break;
|
break;
|
||||||
@ -208,12 +207,6 @@ static const char message_advice_pull_before_push[] =
|
|||||||
"before pushing again.\n"
|
"before pushing again.\n"
|
||||||
"See the 'Note about fast-forwards' in 'git push --help' for details.");
|
"See the 'Note about fast-forwards' in 'git push --help' for details.");
|
||||||
|
|
||||||
static const char message_advice_use_upstream[] =
|
|
||||||
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
|
|
||||||
"counterpart. If you did not intend to push that branch, you may want to\n"
|
|
||||||
"specify branches to push or set the 'push.default' configuration variable\n"
|
|
||||||
"to 'simple', 'current' or 'upstream' to push only the current branch.");
|
|
||||||
|
|
||||||
static const char message_advice_checkout_pull_push[] =
|
static const char message_advice_checkout_pull_push[] =
|
||||||
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
|
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
|
||||||
"counterpart. Check out this branch and merge the remote changes\n"
|
"counterpart. Check out this branch and merge the remote changes\n"
|
||||||
@ -227,13 +220,6 @@ static void advise_pull_before_push(void)
|
|||||||
advise(_(message_advice_pull_before_push));
|
advise(_(message_advice_pull_before_push));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void advise_use_upstream(void)
|
|
||||||
{
|
|
||||||
if (!advice_push_non_ff_default || !advice_push_nonfastforward)
|
|
||||||
return;
|
|
||||||
advise(_(message_advice_use_upstream));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void advise_checkout_pull_push(void)
|
static void advise_checkout_pull_push(void)
|
||||||
{
|
{
|
||||||
if (!advice_push_non_ff_matching || !advice_push_nonfastforward)
|
if (!advice_push_non_ff_matching || !advice_push_nonfastforward)
|
||||||
@ -272,10 +258,7 @@ static int push_with_options(struct transport *transport, int flags)
|
|||||||
advise_pull_before_push();
|
advise_pull_before_push();
|
||||||
break;
|
break;
|
||||||
case NON_FF_OTHER:
|
case NON_FF_OTHER:
|
||||||
if (default_matching_used)
|
advise_checkout_pull_push();
|
||||||
advise_use_upstream();
|
|
||||||
else
|
|
||||||
advise_checkout_pull_push();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user