Thread (1 message) 1 message, 1 author, 2016-06-15

Re: push.default: current vs upstream

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:27
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
Jeff King [off-list ref] writes:
...
quoted
Hmm. So this will actually detect "git push $URL" when $URL matches the
remote's configured URL. I feel like this distinction has come up
before, and we decided not to equate the two. But now I can't remember
where (maybe it when fetching via URL versus via remote?).
This is me merely try to be extra nice without succeeding.
An obvious patch to remove the misguided "be nice and try to see if URLs
are the same" bit should look like this.

 builtin/push.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index 3e18cd3..765b19c 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -97,17 +97,10 @@ static void setup_push_upstream(struct remote *remote)
 	if (branch->merge_nr != 1)
 		die(_("The current branch %s has multiple upstream branches, "
 		    "refusing to push."), branch->name);
-	if (strcmp(branch->remote_name, remote->name)) {
-		struct remote *branch_dest = remote_get(branch->remote_name);
-		const char **branch_dest_url, **dest_url;
-
-		if (!push_url_of_remote(remote, &dest_url) ||
-		    !push_url_of_remote(branch_dest, &branch_dest_url) ||
-		    strcmp(dest_url[0], branch_dest_url[0]))
-			die(_("You are pushing to remote '%s', which is not the "
-			      "upstream of your\ncurrent branch '%s'.\n"),
-			    remote->name, branch->name);
-	}
+	if (strcmp(branch->remote_name, remote->name))
+		die(_("You are pushing to remote '%s', which is not the "
+		      "upstream of your\ncurrent branch '%s'.\n"),
+		    remote->name, branch->name);
 
 	strbuf_addf(&refspec, "%s:%s", branch->name, branch->merge[0]->src);
 	add_refspec(refspec.buf);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help