aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-03-15 14:22:55 -0700
committerJunio C Hamano <gitster@pobox.com>2011-03-15 14:22:55 -0700
commitbde7f7389f56bf570c41c8e3f6b58c367b30472a (patch)
treef80bb6a0d4f6d38ee83f6e491d932636c27da462 /builtin
parente2bbfed10da1753751a1562585d07dc23438449a (diff)
parenta3f5e7a32ec2d885fe6ff7fc14ee91de391f1d72 (diff)
downloadgit-bde7f7389f56bf570c41c8e3f6b58c367b30472a.tar.gz
git-bde7f7389f56bf570c41c8e3f6b58c367b30472a.tar.xz
Merge branch 'mm/push-default-advice'
* mm/push-default-advice: push: better error message when no remote configured push: better error messages when push.default = tracking
Diffstat (limited to 'builtin')
-rw-r--r--builtin/push.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/builtin/push.c b/builtin/push.c
index 31da418cf..c3c2feb94 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -64,14 +64,24 @@ static void set_refspecs(const char **refs, int nr)
}
}
-static void setup_push_upstream(void)
+static void setup_push_upstream(struct remote *remote)
{
struct strbuf refspec = STRBUF_INIT;
struct branch *branch = branch_get(NULL);
if (!branch)
- die("You are not currently on a branch.");
+ die("You are not currently on a branch.\n"
+ "To push the history leading to the current (detached HEAD)\n"
+ "state now, use\n"
+ "\n"
+ " git push %s HEAD:<name-of-remote-branch>\n",
+ remote->name);
if (!branch->merge_nr || !branch->merge)
- die("The current branch %s has no upstream branch.",
+ die("The current branch %s has no upstream branch.\n"
+ "To push the current branch and set the remote as upstream, use\n"
+ "\n"
+ " git push --set-upstream %s %s\n",
+ branch->name,
+ remote->name,
branch->name);
if (branch->merge_nr != 1)
die("The current branch %s has multiple upstream branches, "
@@ -80,7 +90,7 @@ static void setup_push_upstream(void)
add_refspec(refspec.buf);
}
-static void setup_default_push_refspecs(void)
+static void setup_default_push_refspecs(struct remote *remote)
{
switch (push_default) {
default:
@@ -89,7 +99,7 @@ static void setup_default_push_refspecs(void)
break;
case PUSH_DEFAULT_UPSTREAM:
- setup_push_upstream();
+ setup_push_upstream(remote);
break;
case PUSH_DEFAULT_CURRENT:
@@ -147,7 +157,14 @@ static int do_push(const char *repo, int flags)
if (!remote) {
if (repo)
die("bad repository '%s'", repo);
- die("No destination configured to push to.");
+ die("No configured push destination.\n"
+ "Either specify the URL from the command-line or configure a remote repository using\n"
+ "\n"
+ " git remote add <name> <url>\n"
+ "\n"
+ "and then push using the remote name\n"
+ "\n"
+ " git push <name>\n");
}
if (remote->mirror)
@@ -175,7 +192,7 @@ static int do_push(const char *repo, int flags)
refspec = remote->push_refspec;
refspec_nr = remote->push_refspec_nr;
} else if (!(flags & TRANSPORT_PUSH_MIRROR))
- setup_default_push_refspecs();
+ setup_default_push_refspecs(remote);
}
errs = 0;
if (remote->pushurl_nr) {