More inexperienced users will often push right after committing, and at that time they're still very much in the "working-on-one-branch" state of mind. "upstream" would be a safer default mode of operation for 'git push' for them even when they have their personal publishing repository (also in a shared public repository settings, "matching" is rarely the right default mode). In preparation for flipping the default to the "upstream" mode from the "matching" mode that is the upstream default, start warning users when they rely on unconfigured "git push" to default to the "matching" mode. Original patch and commit message by: Junio C Hamano <gitster@xxxxxxxxx> Signed-off-by: Matthieu Moy <Matthieu.Moy@xxxxxxx> --- This patch prepares a transition to 'upstream', unlike the previous version which was advertizing 'current'. In most case, this would be the same, but 'upstream' is probably more sensible in case it points to a branch other than 'current'. I don't care much either way. I've kept the wording from the original patch, which commits to a future change. We may instead relax this commitment and just say "the default is likely to change in a future version", or so. builtin/push.c | 22 ++++++++++++++++++++++ cache.h | 1 + environment.c | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/builtin/push.c b/builtin/push.c index d315475..03545c0 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -91,10 +91,32 @@ static void setup_push_upstream(struct remote *remote) add_refspec(refspec.buf); } +static void warn_unspecified_push_default_configuration(void) +{ + static int warn_once; + + if (warn_once++) + return; + warning(_("push.default is unset; its implicit value is changing in 1.8.0 from\n" + "'matching' to 'upstream'. To squelch this message and maintain the current\n" + "behavior post-1.8.0, use:\n" + "\n" + " git config --global push.default matching\n" + "\n" + "To squelch this message and adopt the 1.8.0 behavior now, use:\n" + "\n" + " git config --global push.default upstream\n" + "\n" + "See 'git help config' and search for 'push.default' for further information.\n")); +} + static void setup_default_push_refspecs(struct remote *remote) { switch (push_default) { default: + case PUSH_DEFAULT_UNSPECIFIED: + warn_unspecified_push_default_configuration(); + /* fallthru */ case PUSH_DEFAULT_MATCHING: add_refspec(":"); break; diff --git a/cache.h b/cache.h index e12b15f..e5c3f26 100644 --- a/cache.h +++ b/cache.h @@ -622,6 +622,7 @@ enum rebase_setup_type { }; enum push_default_type { + PUSH_DEFAULT_UNSPECIFIED = -1, PUSH_DEFAULT_NOTHING = 0, PUSH_DEFAULT_MATCHING, PUSH_DEFAULT_UPSTREAM, diff --git a/environment.c b/environment.c index c93b8f4..d7e6c65 100644 --- a/environment.c +++ b/environment.c @@ -52,7 +52,7 @@ enum safe_crlf safe_crlf = SAFE_CRLF_WARN; unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; enum branch_track git_branch_track = BRANCH_TRACK_REMOTE; enum rebase_setup_type autorebase = AUTOREBASE_NEVER; -enum push_default_type push_default = PUSH_DEFAULT_MATCHING; +enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED; #ifndef OBJECT_CREATION_MODE #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS #endif -- 1.7.9.3.330.g598662 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html