diff --git a/cmd-mount.c b/cmd-mount.c index 542d57e..10a0c5d 100644 --- a/cmd-mount.c +++ b/cmd-mount.c @@ -6,14 +6,13 @@ * See the file COPYING. */ -#define _GNU_SOURCE /* for sigset(), canonicalize_file_name() */ +#include "cache.h" /* from git core */ #include "gitfs.h" #include "defaults.h" #include #include #include #include -#include "cache.h" /* from git core */ /* Set up git to read from the current directory */ static int prepare_git_environment(void) diff --git a/conf.c b/conf.c index b0422ff..f0d6972 100644 --- a/conf.c +++ b/conf.c @@ -230,7 +230,7 @@ int validate_command_line_options_wcount(const struct gitcmd_option *list, return 0; } -static int gitfs_config_file_worker(const char *var, const char *val) +static int gitfs_config_file_worker(const char *var, const char *val, void *cb) { static const char prefix[] = { 'g', 'i', 't', 'f', 's', '.' }; int rv; @@ -251,7 +251,7 @@ int gitfs_server_read_config(void) /* If there's a normal git config file, read it */ if (stat("config", &dummy_st) == 0 && - git_config(gitfs_config_file_worker) != 0) + git_config(gitfs_config_file_worker, NULL) != 0) return -1; /* * Now take all of the entries previously put into the "from_cmd_line" diff --git a/gitfs.h b/gitfs.h index f5fb578..f02af89 100644 --- a/gitfs.h +++ b/gitfs.h @@ -14,6 +14,7 @@ #include #include #include /* for "struct timespec" */ +#include #ifdef __GNUC__ #define likely(x) __builtin_expect(!!(x), 1) diff --git a/gitobj.c b/gitobj.c index 304d2b0..a08f4d2 100644 --- a/gitobj.c +++ b/gitobj.c @@ -725,7 +725,7 @@ static int fill_gitobj_from_worker_result(struct gitobj *gobj, if (unlikely(gobj->type != GFN_INCOMPLETE)) { /* We already got parsed! */ assert(gobj->type == cmd->answer.open.type); - goto done; + goto done_nofree; } switch (cmd->answer.open.type) { case GFN_DIR: @@ -748,8 +748,6 @@ static int fill_gitobj_from_worker_result(struct gitobj *gobj, default: assert(0); } - done: - free(cmd->answer.open.buf); done_nofree: gobj->type = cmd->answer.open.type; return ret; diff --git a/gitworker.c b/gitworker.c index 09e3fd7..604fb9f 100644 --- a/gitworker.c +++ b/gitworker.c @@ -44,7 +44,7 @@ static void gitwork_find_packname(struct gitwork_cmd *cmd) static int raw_resolve_reference(const unsigned char *obuf, unsigned char **nbufp, unsigned long *sizep, const char *ref_str, size_t reflen, - char *type) + enum object_type *type) { struct gitobj_ptr nptr; @@ -52,7 +52,7 @@ static int raw_resolve_reference(const unsigned char *obuf, 0 != memcmp(obuf, ref_str, reflen) || get_sha1_hex((const char *) &obuf[reflen], &nptr.sha1[0]) != 0) return -ENOLINK; - *nbufp = read_sha1_file(&nptr.sha1[0], type, sizep); + *nbufp = read_sha1_file(nptr.sha1, type, sizep); if (*nbufp == NULL) return -ENOENT; return 0; @@ -68,17 +68,17 @@ static int raw_resolve_reference(const unsigned char *obuf, static int git_read(const struct gitobj_ptr *ptr, struct gitwork_open_result *ores) { - char type[20]; + enum object_type type; unsigned char *buf; int res; - buf = read_sha1_file(&ptr->sha1[0], type, &ores->size); + buf = read_sha1_file(ptr->sha1, &type, &ores->size); if (buf == NULL) return -ENOENT; ores->buf = buf; - if (0 == strcmp(type, "tag")) { + if (type == OBJ_TAG) { res = resolve_reference(ores->buf, &buf, - &ores->size, "object", type); + &ores->size, "object", &type); free(ores->buf); if (res != 0) { assert(res < 0); @@ -86,9 +86,9 @@ static int git_read(const struct gitobj_ptr *ptr, } ores->buf = buf; } - if (0 == strcmp(type, "commit")) { + if (type == OBJ_COMMIT) { res = resolve_reference(ores->buf, &buf, - &ores->size, "tree", type); + &ores->size, "tree", &type); free(ores->buf); if (res != 0) { assert(res < 0); @@ -96,9 +96,9 @@ static int git_read(const struct gitobj_ptr *ptr, } ores->buf = buf; } - if (0 == strcmp(type, "tree")) { + if (type == OBJ_TREE) { ores->type = GFN_DIR; - } else if (0 == strcmp(type, "blob")) { + } else if (type == OBJ_BLOB) { ores->type = GFN_FILE; /* Note: this could actually turn out to be a symlink */ } else { @@ -117,10 +117,10 @@ static void gitwork_object_info(struct gitwork_cmd *cmd) */ if (cmd->answer.open.type == GFN_FILE || cmd->answer.open.type == GFN_SYMLINK) { - char type[20]; - if (sha1_object_info(&cmd->gptr->sha1[0], type, + enum object_type type; + if (read_sha1_file(cmd->gptr->sha1, &type, &cmd->answer.open.size) == 0 && - 0 == strcmp(type, "blob")) { + type == OBJ_BLOB) { cmd->error = 0; cmd->answer.open.type = GFN_FILE; cmd->answer.open.buf = NULL; diff --git a/util.c b/util.c index 4614898..3c2bc81 100644 --- a/util.c +++ b/util.c @@ -6,7 +6,7 @@ * See the file COPYING. */ -#define _GNU_SOURCE /* for clock_gettime() */ +#include "cache.h" /* for get_sha1_hex() */ #include "gitfs.h" #include #include @@ -16,7 +16,6 @@ #include #include #include -#include "cache.h" /* for get_sha1_hex() */ int #ifdef __GNUC__