> On 03 Aug 2017, at 10:18, Christian Couder <[email protected]> wrote:
> 
> Let's add an odb_helper_init() function to send an 'init'
> instruction to the helpers. This 'init' instruction is
> especially useful to get the capabilities that are supported
> by the helpers.
> 
> So while at it, let's also add a parse_capabilities()
> function to parse them and a supported_capabilities
> variable in struct odb_helper to store them.
> 
> Signed-off-by: Christian Couder <[email protected]>
> ---
> ...
> 
> +static void parse_capabilities(char *cap_buf,
> +                            unsigned int *supported_capabilities,
> +                            const char *process_name)
> +{
> +     struct string_list cap_list = STRING_LIST_INIT_NODUP;
> +
> +     string_list_split_in_place(&cap_list, cap_buf, '=', 1);
> +
> +     if (cap_list.nr == 2 && !strcmp(cap_list.items[0].string, 
> "capability")) {
> +             const char *cap_name = cap_list.items[1].string;
> +
> +             if (!strcmp(cap_name, "get_git_obj")) {
> +                     *supported_capabilities |= ODB_HELPER_CAP_GET_GIT_OBJ;
> +             } else if (!strcmp(cap_name, "get_raw_obj")) {
> +                     *supported_capabilities |= ODB_HELPER_CAP_GET_RAW_OBJ;
> +             } else if (!strcmp(cap_name, "get_direct")) {
> +                     *supported_capabilities |= ODB_HELPER_CAP_GET_DIRECT;
> +             } else if (!strcmp(cap_name, "put_git_obj")) {
> +                     *supported_capabilities |= ODB_HELPER_CAP_PUT_GIT_OBJ;
> +             } else if (!strcmp(cap_name, "put_raw_obj")) {
> +                     *supported_capabilities |= ODB_HELPER_CAP_PUT_RAW_OBJ;
> +             } else if (!strcmp(cap_name, "put_direct")) {
> +                     *supported_capabilities |= ODB_HELPER_CAP_PUT_DIRECT;
> +             } else if (!strcmp(cap_name, "have")) {
> +                     *supported_capabilities |= ODB_HELPER_CAP_HAVE;
> +             } else {
> +                     warning("external process '%s' requested unsupported 
> read-object capability '%s'",
> +                             process_name, cap_name);
> +             }

In 1514c8ed ("convert: refactor capabilities negotiation", 2017-06-30) I 
introduced
a simpler version of the capabilities negotiation. Maybe useful for you here, 
too? 

- Lars

Reply via email to