commit - 12e242cc147359760295ebf3098d829c208aa52a
commit + 66ca6940e6deb73fc261872c44f4d17c62edc01b
blob - 6fe120ae1d6d0658194eafcc6e7d4f7629c8ca0c
blob + d07ab6f5deab0e040bb8bb59b491b8597722c0be
--- lib/repository.c
+++ lib/repository.c
struct got_repository *repo, const char *id_str_prefix, int obj_type)
{
const struct got_error *err = NULL;
+ char *objects_pack_dir = NULL;
struct got_object_id_queue matched_ids;
struct got_pathlist_entry *pe;
struct stat sb;
STAILQ_INIT(&matched_ids);
- if (stat(got_repo_get_path_objects_pack(repo), &sb) == -1) {
- if (errno != ENOENT)
- return got_error_from_errno2("stat",
- got_repo_get_path_objects_pack(repo));
+ objects_pack_dir = got_repo_get_path_objects_pack(repo);
+ if (objects_pack_dir == NULL)
+ return got_error_from_errno("got_repo_get_path_objects_pack");
+
+ if (stat(objects_pack_dir, &sb) == -1) {
+ if (errno != ENOENT) {
+ err = got_error_from_errno2("stat", objects_pack_dir);
+ goto done;
+ }
} else if (sb.st_mtime != repo->pack_path_mtime) {
purge_packidx_paths(&repo->packidx_paths);
err = got_repo_list_packidx(&repo->packidx_paths, repo);
if (err)
- return err;
+ goto done;
}
TAILQ_FOREACH(pe, &repo->packidx_paths, entry) {
}
}
done:
+ free(objects_pack_dir);
got_object_id_queue_free(&matched_ids);
if (err) {
free(*unique_id);
const char *id_str_prefix, int obj_type, struct got_repository *repo)
{
const struct got_error *err = NULL;
- char *path_objects = got_repo_get_path_objects(repo);
- char *object_dir = NULL;
+ char *path_objects = NULL, *object_dir = NULL;
size_t len;
int i;
*id = NULL;
+ path_objects = got_repo_get_path_objects(repo);
+
len = strlen(id_str_prefix);
- if (len > SHA1_DIGEST_STRING_LENGTH - 1)
- return got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR);
+ if (len > SHA1_DIGEST_STRING_LENGTH - 1) {
+ err = got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR);
+ goto done;
+ }
for (i = 0; i < len; i++) {
if (isxdigit((unsigned char)id_str_prefix[i]))
continue;
- return got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR);
+ err = got_error_path(id_str_prefix, GOT_ERR_BAD_OBJ_ID_STR);
+ goto done;
}
if (len >= 2) {
goto done;
}
done:
+ free(path_objects);
free(object_dir);
if (err) {
free(*id);