Commit Diff


commit - 35a11c8a7a3ae3f902bdddd1eb91c23982c612b0
commit + dcb4802348688d5dd006cb17f1ce3045a9791b35
blob - a31098e14ec3916c567d922a117d7d74baf597a8
blob + acdbcf213622afbf5553af4a03676be3862379b8
--- lib/got_lib_pack.h
+++ lib/got_lib_pack.h
@@ -57,9 +57,9 @@ const struct got_error *got_pack_parse_object_type_and
 #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 - 606d32e822167999828d4333a09b3b6ee296bf61
blob + 825c284a4e4d1d2d2a5c1a4d62d6ba968820390a
--- lib/got_lib_repository.h
+++ lib/got_lib_repository.h
@@ -159,7 +159,7 @@ const struct got_error*got_repo_cache_raw_object(struc
     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 - 47e4642c06e4806292166b184a34bedafab3eb6c
blob + e25d7c6f309c6ab9ea5bd88e7e3dceab290ba031
--- lib/repository.c
+++ lib/repository.c
@@ -1182,16 +1182,21 @@ cache_packidx(struct got_repository *repo, struct got_
 }
 
 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;
@@ -1442,7 +1447,8 @@ got_repo_list_packidx(struct got_pathlist_head *packid
 	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,
@@ -2553,7 +2559,8 @@ got_repo_get_packfile_info(int *npackfiles, int *nobje
 	}
 
 	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 - da0b3b49fa523700d29c8be5ec7542ae6ecc9c4e
blob + cf40a58dbaf2381f06e5e93fe1cdf138e1a72a9c
--- lib/repository_admin.c
+++ lib/repository_admin.c
@@ -1537,7 +1537,8 @@ got_repo_remove_lonely_packidx(struct got_repository *
 				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,