As there will be different kinds of helpers, let's add an "enum odb_helper_type" to tell between the different kinds. Let's add a field with this type in "struct odb_helper", and set it when reading the config file. While at it let's also make it possible to find an helper of a specific kind by adding a new find_odb_helper() function. Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx> --- external-odb.c | 13 +++++++++++++ external-odb.h | 10 ++++++++++ odb-helper.h | 3 +++ 3 files changed, 26 insertions(+) diff --git a/external-odb.c b/external-odb.c index 5d0afb9762..9c77180d6c 100644 --- a/external-odb.c +++ b/external-odb.c @@ -57,6 +57,19 @@ int has_external_odb(void) return !!helpers; } +struct odb_helper *find_odb_helper(const char *dealer, enum odb_helper_type type) +{ + struct odb_helper *o; + + external_odb_init(); + + for (o = helpers; o; o = o->next) + if (!strcmp(o->dealer, dealer) && o->type == type) + return o; + + return NULL; +} + const char *external_odb_root(void) { static const char *root; diff --git a/external-odb.h b/external-odb.h index fd6708163e..27c3d39c1b 100644 --- a/external-odb.h +++ b/external-odb.h @@ -1,7 +1,17 @@ #ifndef EXTERNAL_ODB_H #define EXTERNAL_ODB_H +enum odb_helper_type { + ODB_HELPER_NONE = 0, + ODB_HELPER_GIT_REMOTE, + ODB_HELPER_SCRIPT_CMD, + ODB_HELPER_SUBPROCESS_CMD, + OBJ_HELPER_MAX +}; + extern int has_external_odb(void); +extern struct odb_helper *find_odb_helper(const char *dealer, + enum odb_helper_type type); extern const char *external_odb_root(void); extern int external_odb_has_object(const unsigned char *sha1); extern int external_odb_get_direct(const unsigned char *sha1); diff --git a/odb-helper.h b/odb-helper.h index 57b14fe814..d4b968693f 100644 --- a/odb-helper.h +++ b/odb-helper.h @@ -1,9 +1,12 @@ #ifndef ODB_HELPER_H #define ODB_HELPER_H +#include "external-odb.h" + struct odb_helper { const char *name; const char *dealer; + enum odb_helper_type type; struct odb_helper_object { struct object_id oid; -- 2.17.0.rc0.37.g8f476fabe9