The script calling git push --dry-run --porcelain can see clearly from the output that the updates will be rejected. However, it will probably need to distinguish this condition from the push failing for other reasons, such as the remote not being reachable. Signed-off-by: Larry D'Anna <larry@xxxxxxxxxxxxxx> --- builtin-send-pack.c | 5 +++++ send-pack.h | 1 + transport.c | 11 +++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/builtin-send-pack.c b/builtin-send-pack.c index 76c7206..dfd7470 100644 --- a/builtin-send-pack.c +++ b/builtin-send-pack.c @@ -478,6 +478,11 @@ int send_pack(struct send_pack_args *args, return ret; for (ref = remote_refs; ref; ref = ref->next) { switch (ref->status) { + case REF_STATUS_REJECT_NONFASTFORWARD: + case REF_STATUS_REJECT_NODELETE: + if (args->porcelain && args->dry_run) + break; + return -1; case REF_STATUS_NONE: case REF_STATUS_UPTODATE: case REF_STATUS_OK: diff --git a/send-pack.h b/send-pack.h index 28141ac..60b4ba6 100644 --- a/send-pack.h +++ b/send-pack.h @@ -4,6 +4,7 @@ struct send_pack_args { unsigned verbose:1, quiet:1, + porcelain:1, send_mirror:1, force_update:1, use_thin_pack:1, diff --git a/transport.c b/transport.c index f707c7b..e61d288 100644 --- a/transport.c +++ b/transport.c @@ -558,10 +558,16 @@ static int fetch_refs_via_pack(struct transport *transport, return (refs ? 0 : -1); } -static int push_had_errors(struct ref *ref) +static int push_had_errors(struct ref *ref, int flags) { for (; ref; ref = ref->next) { switch (ref->status) { + case REF_STATUS_REJECT_NONFASTFORWARD: + case REF_STATUS_REJECT_NODELETE: + if (flags & TRANSPORT_PUSH_DRY_RUN && flags & TRANSPORT_PUSH_PORCELAIN) + break; + else + return 1; case REF_STATUS_NONE: case REF_STATUS_UPTODATE: case REF_STATUS_OK: @@ -791,6 +797,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re args.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE); args.quiet = !!(flags & TRANSPORT_PUSH_QUIET); args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN); + args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN); ret = send_pack(&args, data->fd, data->conn, remote_refs, &data->extra_have); @@ -1052,7 +1059,7 @@ int transport_push(struct transport *transport, flags & TRANSPORT_PUSH_FORCE); ret = transport->push_refs(transport, remote_refs, flags); - err = push_had_errors(remote_refs); + err = push_had_errors(remote_refs, flags); ret |= err; -- 1.7.0.rc1.33.g07cf0f.dirty -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html