diff options
author | Finn Arne Gangstad <finnag@pvv.org> | 2009-03-16 16:42:52 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-17 14:50:21 -0700 |
commit | 665d3e8f057b90d7b43d70db75b9ac5506bd204d (patch) | |
tree | 1523103127b9ff34f0062958681076518cf405cd /builtin-push.c | |
parent | 521537476fe99b97bfcdf1b8f0c579061af5fd3e (diff) | |
download | git-665d3e8f057b90d7b43d70db75b9ac5506bd204d.tar.gz |
Display warning for default git push with no push.default config
If a git push without any refspecs is attempted, display a warning.
The current default behavior is to push all matching refspecs, which
may come as a surprise to new users, so the warning shows how
push.default can be configured and what the possible values are.
Traditionalists who wish to keep the current behaviour are also told
how to configure this once and never see the warning again.
Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-push.c')
-rw-r--r-- | builtin-push.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/builtin-push.c b/builtin-push.c index 45fe843b20..8f4fa5b09e 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -64,11 +64,34 @@ static void setup_push_tracking(void) add_refspec(refspec.buf); } +static const char *warn_unconfigured_push_msg[] = { + "You did not specify any refspecs to push, and the current remote", + "has not configured any push refspecs. The default action in this", + "case is to push all matching refspecs, that is, all branches", + "that exist both locally and remotely will be updated. This may", + "not necessarily be what you want to happen.", + "", + "You can specify what action you want to take in this case, and", + "avoid seeing this message again, by configuring 'push.default' to:", + " 'nothing' : Do not push anythig", + " 'matching' : Push all matching branches (default)", + " 'tracking' : Push the current branch to whatever it is tracking", + " 'current' : Push the current branch" +}; + +static void warn_unconfigured_push(void) +{ + int i; + for (i = 0; i < ARRAY_SIZE(warn_unconfigured_push_msg); i++) + warning("%s", warn_unconfigured_push_msg[i]); +} + static void setup_default_push_refspecs(void) { git_config(git_default_config, NULL); switch (push_default) { case PUSH_DEFAULT_UNSPECIFIED: + warn_unconfigured_push(); /* fallthrough */ case PUSH_DEFAULT_MATCHING: |