From 4f39cd821d1756f5f6d145f987576660136931ee Mon Sep 17 00:00:00 2001 From: Jonathan Tan Date: Fri, 18 Aug 2017 15:20:16 -0700 Subject: pack: move pack name-related functions Currently, sha1_file.c and cache.h contain many functions, both related to and unrelated to packfiles. This makes both files very large and causes an unclear separation of concerns. Create a new file, packfile.c, to hold all packfile-related functions currently in sha1_file.c. It has a corresponding header packfile.h. In this commit, the pack name-related functions are moved. Subsequent commits will move the other functions. Signed-off-by: Jonathan Tan Signed-off-by: Junio C Hamano --- packfile.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packfile.c (limited to 'packfile.c') diff --git a/packfile.c b/packfile.c new file mode 100644 index 0000000000..0d191dfd60 --- /dev/null +++ b/packfile.c @@ -0,0 +1,23 @@ +#include "cache.h" + +char *odb_pack_name(struct strbuf *buf, + const unsigned char *sha1, + const char *ext) +{ + strbuf_reset(buf); + strbuf_addf(buf, "%s/pack/pack-%s.%s", get_object_directory(), + sha1_to_hex(sha1), ext); + return buf->buf; +} + +char *sha1_pack_name(const unsigned char *sha1) +{ + static struct strbuf buf = STRBUF_INIT; + return odb_pack_name(&buf, sha1, "pack"); +} + +char *sha1_pack_index_name(const unsigned char *sha1) +{ + static struct strbuf buf = STRBUF_INIT; + return odb_pack_name(&buf, sha1, "idx"); +} -- cgit v1.2.3