push: return reject reasons as a bitset

Pass all rejection reasons back from transport_push().  The logic is
simpler and more flexible with regard to providing useful feedback.

Signed-off-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Chris Rorvick
2012-11-29 19:41:33 -06:00
committed by Junio C Hamano
parent b0b00a3ee4
commit 10643d4ec3
4 changed files with 19 additions and 24 deletions

View File

@ -244,7 +244,7 @@ static void advise_checkout_pull_push(void)
static int push_with_options(struct transport *transport, int flags)
{
int err;
int nonfastforward;
unsigned int reject_reasons;
transport_set_verbosity(transport, verbosity, progress);
@ -257,7 +257,7 @@ static int push_with_options(struct transport *transport, int flags)
if (verbosity > 0)
fprintf(stderr, _("Pushing to %s\n"), transport->url);
err = transport_push(transport, refspec_nr, refspec, flags,
&nonfastforward);
&reject_reasons);
if (err != 0)
error(_("failed to push some refs to '%s'"), transport->url);
@ -265,18 +265,13 @@ static int push_with_options(struct transport *transport, int flags)
if (!err)
return 0;
switch (nonfastforward) {
default:
break;
case NON_FF_HEAD:
if (reject_reasons & REJECT_NON_FF_HEAD) {
advise_pull_before_push();
break;
case NON_FF_OTHER:
} else if (reject_reasons & REJECT_NON_FF_OTHER) {
if (default_matching_used)
advise_use_upstream();
else
advise_checkout_pull_push();
break;
}
return 1;