From ba928c13d75172799f5f06f922e5c2f3232cf114 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 5 Mar 2014 14:04:54 -0500 Subject: push: detect local refspec errors early When pushing, we do not even look at our push refspecs until after we have made contact with the remote receive-pack and gotten its list of refs. This means that we may go to some work, including asking the user to log in, before realizing we have simple errors like "git push origin matser". We cannot catch all refspec problems, since fully evaluating the refspecs requires knowing what the remote side has. But we can do a quick sanity check of the local side and catch a few simple error cases. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- transport.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'transport.c') diff --git a/transport.c b/transport.c index ca7bb441b..325f03e1e 100644 --- a/transport.c +++ b/transport.c @@ -1132,8 +1132,7 @@ int transport_push(struct transport *transport, return transport->push(transport, refspec_nr, refspec, flags); } else if (transport->push_refs) { - struct ref *remote_refs = - transport->get_refs_list(transport, 1); + struct ref *remote_refs; struct ref *local_refs = get_local_heads(); int match_flags = MATCH_REFS_NONE; int verbose = (transport->verbose > 0); @@ -1142,6 +1141,11 @@ int transport_push(struct transport *transport, int pretend = flags & TRANSPORT_PUSH_DRY_RUN; int push_ret, ret, err; + if (check_push_refs(local_refs, refspec_nr, refspec) < 0) + return -1; + + remote_refs = transport->get_refs_list(transport, 1); + if (flags & TRANSPORT_PUSH_ALL) match_flags |= MATCH_REFS_ALL; if (flags & TRANSPORT_PUSH_MIRROR) -- cgit v1.2.1