@@ -630,7 +630,7 @@ int send_pack(struct send_pack_args *args,
reject_atomic_push(remote_refs, args->send_mirror);
error("atomic push failed for ref %s. status: %d",
ref->name, ref->status);
- ret = args->porcelain ? 0 : -1;
+ ret = ERROR_SEND_PACK_BAD_REF_STATUS;
goto out;
}
/* else fallthrough */
@@ -761,11 +761,6 @@ int send_pack(struct send_pack_args *args,
if (ret < 0)
goto out;
- if (args->porcelain) {
- ret = 0;
- goto out;
- }
-
for (ref = remote_refs; ref; ref = ref->next) {
switch (ref->status) {
case REF_STATUS_NONE:
@@ -773,7 +768,7 @@ int send_pack(struct send_pack_args *args,
case REF_STATUS_OK:
break;
default:
- ret = -1;
+ ret = ERROR_SEND_PACK_BAD_REF_STATUS;
goto out;
}
}
@@ -12,6 +12,9 @@ struct ref;
#define SEND_PACK_PUSH_CERT_IF_ASKED 1
#define SEND_PACK_PUSH_CERT_ALWAYS 2
+/* Custom exit code from send_pack. */
+#define ERROR_SEND_PACK_BAD_REF_STATUS 1
+
struct send_pack_args {
const char *url;
unsigned verbose:1,
@@ -914,6 +914,13 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
case protocol_v0:
ret = send_pack(&args, data->fd, data->conn, remote_refs,
&data->extra_have);
+ /*
+ * Ignore the specific error code to maintain consistent behavior
+ * with the "push_refs()" function across different transports,
+ * such as "push_refs_with_push()" for HTTP protocol.
+ */
+ if (ret == ERROR_SEND_PACK_BAD_REF_STATUS)
+ ret = 0;
break;
case protocol_unknown_version:
BUG("unknown protocol version");