sha1_file: allow sha1_file_name to handle arbitrary repositories
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Mar 23, 2018 at 18:21 UTC
a68377b5dedbe7e5230901577eac9b9a00cb26b4
2 files changed
+3
-4
object-store.h
+1
-2
@@ -125,8 +125,7 @@ void raw_object_store_clear(struct raw_object_store *o);
125
* Put in `buf` the name of the file in the local object database that
126
* would be used to store a loose object with the specified sha1.
127
*/
128
-#define sha1_file_name(r, b, s) sha1_file_name_##r(b, s)
129
-void sha1_file_name_the_repository(struct strbuf *buf, const unsigned char *sha1);
128
+void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned char *sha1);
129
130
#define map_sha1_file(r, s, sz) map_sha1_file_##r(s, sz)
131
void *map_sha1_file_the_repository(const unsigned char *sha1, unsigned long *size);
sha1_file.c
+2
-2
@@ -323,9 +323,9 @@ static void fill_sha1_path(struct strbuf *buf, const unsigned char *sha1)
323
}
324
}
325
326
-void sha1_file_name_the_repository(struct strbuf *buf, const unsigned char *sha1)
326
+void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned char *sha1)
327
{
328
- strbuf_addstr(buf, get_object_directory());
328
+ strbuf_addstr(buf, r->objects->objectdir);
329
strbuf_addch(buf, '/');
330
fill_sha1_path(buf, sha1);
331
}