commit - 2e17b4a13c5799df8b2f315a4e457d35a7571597
commit + c66ecbcb0a2490fb69c7a79d2b794fa9404c3053
blob - 24d85f2fa225eeb6a74df6629dfac15beadc10e2
blob + d3b6994a05d5085b0c9f884e065b83e780ee138a
--- lib/got_lib_pack.h
+++ lib/got_lib_pack.h
#define GOT_PACK_PREFIX "pack-"
#define GOT_PACKFILE_SUFFIX ".pack"
-#define GOT_PACKIDX_SUFFIX ".idx"
+#define GOT_PACKIDX_SUFFIX ".idx"
#define GOT_PACKFILE_NAMELEN (strlen(GOT_PACK_PREFIX) + \
SHA1_DIGEST_STRING_LENGTH - 1 + \
strlen(GOT_PACKFILE_SUFFIX))
-#define GOT_PACKIDX_NAMELEN (strlen(GOT_PACK_PREFIX) + \
- SHA1_DIGEST_STRING_LENGTH - 1 + \
- strlen(GOT_PACKIDX_SUFFIX))
+#define GOT_PACKIDX_NAMELEN(digest_len) \
+ (strlen(GOT_PACK_PREFIX) + \
+ digest_len - 1 + strlen(GOT_PACKIDX_SUFFIX))
/* See Documentation/technical/pack-format.txt in Git. */
blob - 38259e224eecc4b0deaaaff9b35ca1c7e54810fb
blob + 8fefaac3f27e98588e2870aa8a677ca4e4f8cade
--- lib/got_lib_repository.h
+++ lib/got_lib_repository.h
struct got_object_id *, struct got_raw_object *);
struct got_raw_object *got_repo_get_cached_raw_object(struct got_repository *,
struct got_object_id *);
-int got_repo_is_packidx_filename(const char *, size_t);
+int got_repo_is_packidx_filename(const char *, size_t, enum got_hash_algorithm);
int got_repo_check_packidx_bloom_filter(struct got_repository *,
const char *, struct got_object_id *);
const struct got_error *got_repo_search_packidx(struct got_packidx **, int *,
blob - a1c5c2856e555e0180042bbcf838e6e61f6814ea
blob + 16e3d306e6c4520d50d972c00ad7ccd52541d09f
--- lib/repository.c
+++ lib/repository.c
}
int
-got_repo_is_packidx_filename(const char *name, size_t len)
+got_repo_is_packidx_filename(const char *name, size_t len,
+ enum got_hash_algorithm algo)
{
- if (len != GOT_PACKIDX_NAMELEN)
+ size_t idlen;
+
+ idlen = got_hash_digest_string_length(algo);
+
+ if (len != GOT_PACKIDX_NAMELEN(idlen))
return 0;
if (strncmp(name, GOT_PACK_PREFIX, strlen(GOT_PACK_PREFIX)) != 0)
return 0;
- if (strcmp(name + strlen(GOT_PACK_PREFIX) +
- SHA1_DIGEST_STRING_LENGTH - 1, GOT_PACKIDX_SUFFIX) != 0)
+ if (strcmp(name + strlen(GOT_PACK_PREFIX) + idlen - 1,
+ GOT_PACKIDX_SUFFIX) != 0)
return 0;
return 1;
repo->pack_path_mtime.tv_nsec = sb.st_mtim.tv_nsec;
while ((dent = readdir(packdir)) != NULL) {
- if (!got_repo_is_packidx_filename(dent->d_name, dent->d_namlen))
+ if (!got_repo_is_packidx_filename(dent->d_name, dent->d_namlen,
+ repo->algo))
continue;
if (asprintf(&path_packidx, "%s/%s", GOT_OBJECTS_PACK_DIR,
}
while ((dent = readdir(packdir)) != NULL) {
- if (!got_repo_is_packidx_filename(dent->d_name, dent->d_namlen))
+ if (!got_repo_is_packidx_filename(dent->d_name, dent->d_namlen,
+ repo->algo))
continue;
if (asprintf(&path_packidx, "%s/%s", GOT_OBJECTS_PACK_DIR,
blob - 522c3393ca3e3bce08a4efda7994f68d175a30b1
blob + e77be5b3d71e288c7b91770b3d71f373f26ead78
--- lib/repository_admin.c
+++ lib/repository_admin.c
goto done;
}
- if (!got_repo_is_packidx_filename(dent->d_name, dent->d_namlen))
+ if (!got_repo_is_packidx_filename(dent->d_name, dent->d_namlen,
+ got_repo_get_object_format(repo)))
continue;
err = got_packidx_get_packfile_path(&pack_relpath,