ref->deletion ? NULL : ref->peer_ref,
"remote failed to report status", porcelain);
break;
+ case REF_STATUS_ATOMIC_PUSH_FAILED:
+ print_ref_status('!', "[rejected]", ref, ref->peer_ref,
+ "atomic push failed", porcelain);
+ break;
case REF_STATUS_OK:
print_ok_ref_status(ref, porcelain);
break;
args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
args.porcelain = !!(flags & TRANSPORT_PUSH_PORCELAIN);
args.push_cert = !!(flags & TRANSPORT_PUSH_CERT);
+ args.atomic = !!(flags & TRANSPORT_PUSH_ATOMIC);
args.url = transport->url;
ret = send_pack(&args, data->fd, data->conn, remote_refs,
return strchr(url, ':') - url;
}
-void transport_check_allowed(const char *type)
+static const struct string_list *protocol_whitelist(void)
{
- struct string_list allowed = STRING_LIST_INIT_DUP;
- const char *v = getenv("GIT_ALLOW_PROTOCOL");
+ static int enabled = -1;
+ static struct string_list allowed = STRING_LIST_INIT_DUP;
+
+ if (enabled < 0) {
+ const char *v = getenv("GIT_ALLOW_PROTOCOL");
+ if (v) {
+ string_list_split(&allowed, v, ':', -1);
+ string_list_sort(&allowed);
+ enabled = 1;
+ } else {
+ enabled = 0;
+ }
+ }
- if (!v)
- return;
+ return enabled ? &allowed : NULL;
+}
- string_list_split(&allowed, v, ':', -1);
- if (!unsorted_string_list_has_string(&allowed, type))
+int is_transport_allowed(const char *type)
+{
+ const struct string_list *allowed = protocol_whitelist();
+ return !allowed || string_list_has_string(allowed, type);
+}
+
+void transport_check_allowed(const char *type)
+{
+ if (!is_transport_allowed(type))
die("transport '%s' not allowed", type);
- string_list_clear(&allowed, 0);
+}
+
+int transport_restrict_protocols(void)
+{
+ return !!protocol_whitelist();
}
struct transport *transport_get(struct remote *remote, const char *url)