From 10643d4ec3b9c5898d93d1c20e98b2ff1906bf79 Mon Sep 17 00:00:00 2001 From: Chris Rorvick Date: Thu, 29 Nov 2012 19:41:33 -0600 Subject: 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 Signed-off-by: Junio C Hamano --- builtin/push.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'builtin/push.c') diff --git a/builtin/push.c b/builtin/push.c index db9ba30b08..9d17fc799c 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -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; -- cgit v1.2.1