Commit Diff


commit - c6e8a8268ec4f4240d51dcfd54d05c5370060747
commit + 509c99732c4da3e3b74c17d09aba5a38b701716f
blob - 39aa4333097646e6b90b09899df9869839a65c43
blob + 8ba2e5dff14da3efda11c6efbcaa5ba9f743c2b3
--- lib/got_lib_pack.h
+++ lib/got_lib_pack.h
@@ -170,6 +170,7 @@ const struct got_error *got_packidx_init_hdr(struct go
 const struct got_error *got_packidx_open(struct got_packidx **,
     int, const char *, int);
 const struct got_error *got_packidx_close(struct got_packidx *);
+const struct got_error *got_packidx_get_packfile_path(char **, struct got_packidx *);
 int got_packidx_get_object_idx(struct got_packidx *, struct got_object_id *);
 const struct got_error *got_packidx_match_id_str_prefix(
     struct got_object_id_queue *, struct got_packidx *, const char *);
blob - 6941187fce5faf795c7ca119dabfdb71231aff1b
blob + 45d8d172d3e1fc86252195cf8d104b348ef56f44
--- lib/object.c
+++ lib/object.c
@@ -146,31 +146,6 @@ done:
 }
 
 static const struct got_error *
-get_packfile_path(char **path_packfile, struct got_packidx *packidx)
-{
-	size_t size;
-
-	/* Packfile path contains ".pack" instead of ".idx", so add one byte. */
-	size = strlen(packidx->path_packidx) + 2;
-	if (size < GOT_PACKFILE_NAMELEN + 1)
-		return got_error_path(packidx->path_packidx, GOT_ERR_BAD_PATH);
-
-	*path_packfile = malloc(size);
-	if (*path_packfile == NULL)
-		return got_error_from_errno("malloc");
-
-	/* Copy up to and excluding ".idx". */
-	if (strlcpy(*path_packfile, packidx->path_packidx,
-	    size - strlen(GOT_PACKIDX_SUFFIX) - 1) >= size)
-		return got_error(GOT_ERR_NO_SPACE);
-
-	if (strlcat(*path_packfile, GOT_PACKFILE_SUFFIX, size) >= size)
-		return got_error(GOT_ERR_NO_SPACE);
-
-	return NULL;
-}
-
-static const struct got_error *
 request_packed_object(struct got_object **obj, struct got_pack *pack, int idx,
     struct got_object_id *id)
 {
@@ -371,7 +346,7 @@ open_packed_object(struct got_object **obj, struct got
 	if (err)
 		return err;
 
-	err = get_packfile_path(&path_packfile, packidx);
+	err = got_packidx_get_packfile_path(&path_packfile, packidx);
 	if (err)
 		return err;
 
@@ -580,7 +555,7 @@ got_object_raw_open(struct got_raw_object **obj, struc
 	if (err == NULL) {
 		struct got_pack *pack = NULL;
 
-		err = get_packfile_path(&path_packfile, packidx);
+		err = got_packidx_get_packfile_path(&path_packfile, packidx);
 		if (err)
 			goto done;
 
@@ -867,7 +842,7 @@ open_commit(struct got_commit_object **commit,
 	if (err == NULL) {
 		struct got_pack *pack = NULL;
 
-		err = get_packfile_path(&path_packfile, packidx);
+		err = got_packidx_get_packfile_path(&path_packfile, packidx);
 		if (err)
 			return err;
 
@@ -1056,7 +1031,7 @@ open_tree(struct got_tree_object **tree, struct got_re
 	if (err == NULL) {
 		struct got_pack *pack = NULL;
 
-		err = get_packfile_path(&path_packfile, packidx);
+		err = got_packidx_get_packfile_path(&path_packfile, packidx);
 		if (err)
 			return err;
 
@@ -1420,7 +1395,7 @@ open_blob(struct got_blob_object **blob, struct got_re
 	if (err == NULL) {
 		struct got_pack *pack = NULL;
 
-		err = get_packfile_path(&path_packfile, packidx);
+		err = got_packidx_get_packfile_path(&path_packfile, packidx);
 		if (err)
 			goto done;
 
@@ -1770,7 +1745,7 @@ open_tag(struct got_tag_object **tag, struct got_repos
 	if (err == NULL) {
 		struct got_pack *pack = NULL;
 
-		err = get_packfile_path(&path_packfile, packidx);
+		err = got_packidx_get_packfile_path(&path_packfile, packidx);
 		if (err)
 			return err;
 
@@ -2274,7 +2249,7 @@ got_traverse_packed_commits(struct got_object_id_queue
 		return NULL;
 	}
 
-	err = get_packfile_path(&path_packfile, packidx);
+	err = got_packidx_get_packfile_path(&path_packfile, packidx);
 	if (err)
 		return err;
 
blob - ee37e1005b535f08ac796a6547d42f3394b34916
blob + 137217342b5f0eb662a63182136a6750ffa7e2af
--- lib/pack.c
+++ lib/pack.c
@@ -414,7 +414,32 @@ got_packidx_close(struct got_packidx *packidx)
 
 	return err;
 }
+
+const struct got_error *
+got_packidx_get_packfile_path(char **path_packfile, struct got_packidx *packidx)
+{
+	size_t size;
+
+	/* Packfile path contains ".pack" instead of ".idx", so add one byte. */
+	size = strlen(packidx->path_packidx) + 2;
+	if (size < GOT_PACKFILE_NAMELEN + 1)
+		return got_error_path(packidx->path_packidx, GOT_ERR_BAD_PATH);
 
+	*path_packfile = malloc(size);
+	if (*path_packfile == NULL)
+		return got_error_from_errno("malloc");
+
+	/* Copy up to and excluding ".idx". */
+	if (strlcpy(*path_packfile, packidx->path_packidx,
+	    size - strlen(GOT_PACKIDX_SUFFIX) - 1) >= size)
+		return got_error(GOT_ERR_NO_SPACE);
+
+	if (strlcat(*path_packfile, GOT_PACKFILE_SUFFIX, size) >= size)
+		return got_error(GOT_ERR_NO_SPACE);
+
+	return NULL;
+}
+
 static off_t
 get_object_offset(struct got_packidx *packidx, int idx)
 {