romele / git-trace public
62 commits · 1 branch · 1 tag · 1 contributor (top: Romele) · first commit 3d ago · last push 12m ago
src/repo.h
#ifndef GT_REPO_H #define GT_REPO_H #include <stddef.h> /* * Repository name policy: [A-Za-z0-9][A-Za-z0-9._-]{0,63} * - first char alphanumeric => blocks ".", "..", hidden names, leading '-' * - '/' excluded => a component can never escape its directory * - ".." substring rejected => belt & braces even though the above suffice */ int name_ok(const char *s); /* name_ok OR the special "_" ownerless namespace */ int owner_ok(const char *s); /* * Build <root>/<owner>/<name>.git into out. Both components are * validated and the result is realpath()'d and required to stay * inside the canonicalised root. Returns 0 on success. */ int repo_path(char *out, size_t outlen, const char *root, const char *owner, const char *name); /* does the bare repo directory exist under root? */ int repo_exists(const char *root, const char *owner, const char *name); struct app_ctx; /* init --bare + install hooks + DB registration; 0 on success */ int repo_create(struct app_ctx *c, int owner_uid, const char *owner, const char *name, const char *desc, int is_private); /* (re)write hooks/update inside an existing bare repo dir */ int repo_install_hooks(struct app_ctx *c, const char *rdir); #endif