From: Karthik Nayak Date: Mon, 26 Oct 2026 11:22:38 GMT Subject: Re: [PATCH v3 2/7] setup: introduce object storage extension Message-ID: In-Reply-To: <20261023-b4-pks-odb-extension-v3-2-b1bb30a006db@pks.im> Patrick Steinhardt writes: [snip] > diff --git a/odb.c b/odb.c > index 98c5c862f5..0649622bc6 100644 > --- a/odb.c > +++ b/odb.c > @@ -27,6 +27,42 @@ > #include "trace2.h" > #include "write-or-die.h" > > +static const char * const object_storage_name_by_format[] = { > + [OBJECT_STORAGE_FORMAT_UNKNOWN] = "unknown", > + [OBJECT_STORAGE_FORMAT_FILES] = "files", > +}; > + Super Nit: I would have dropped from this, as that is the default, this makes it seem like it is one of the backends. Feel free to ignore though. > +enum object_storage_format object_storage_format_by_name(const char *name) > +{ > + for (size_t i = 0; i < ARRAY_SIZE(object_storage_name_by_format); i++) > + if (!strcmp(object_storage_name_by_format[i], name)) > + return i; > + return OBJECT_STORAGE_FORMAT_UNKNOWN; > +} > + > +enum object_storage_format object_storage_format_by_uri(const char *uri, char **payload) > +{ > + enum object_storage_format format; > + const char *schema_end; > + char *name; > + > + schema_end = strstr(uri, "://"); > + if (!schema_end) { > + name = xstrdup(uri); > + if (payload) > + *payload = NULL; > + } else { > + name = xstrndup(uri, schema_end - uri); > + if (payload) > + *payload = *(schema_end + 3) ? xstrdup(schema_end + 3) : NULL; > + } > + > + format = object_storage_format_by_name(name); > + > + free(name); We need to allocate since we only want to send the format and not the payload, makes sense. > + return format; > +} > + > > int odb_mkstemp(struct object_database *odb, > struct strbuf *temp_filename, const char *pattern) > { [snip] > diff --git a/repository.h b/repository.h > index 2a348012e8..8c4437762e 100644 > --- a/repository.h > +++ b/repository.h > @@ -694,6 +708,7 @@ static enum extension_result handle_extension(const char *var, > data->submodule_path_cfg = git_config_bool(var, value); > return EXTENSION_OK; > } > + Nit: stray newline addition > return EXTENSION_UNKNOWN; > } > [snip] The patch looks to be in order!