summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2016-10-03 16:35:31 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-10-10 13:52:36 -0700
commit7f0fa2c02a6543bdadae3c4a492daae7dbc8c042 (patch)
tree5fc856fb9a95e4e5edc2c5d2c980d14f984ce8a8 /sha1_name.c
parentalternates: provide helper for adding to alternates list (diff)
downloadtgif-7f0fa2c02a6543bdadae3c4a492daae7dbc8c042.tar.xz
alternates: provide helper for allocating alternate
Allocating a struct alternate_object_database is tricky, as we must over-allocate the buffer to provide scratch space, and then put in particular '/' and NUL markers. Let's encapsulate this in a function so that the complexity doesn't leak into callers (and so that we can modify it later). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/sha1_name.c b/sha1_name.c
index faf873cf7f..98152a68ba 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -86,12 +86,7 @@ static void find_short_object_filename(int len, const char *hex_pfx, struct disa
* alt->name/alt->base while iterating over the
* object databases including our own.
*/
- const char *objdir = get_object_directory();
- size_t objdir_len = strlen(objdir);
- fakeent = xmalloc(st_add3(sizeof(*fakeent), objdir_len, 43));
- memcpy(fakeent->base, objdir, objdir_len);
- fakeent->name = fakeent->base + objdir_len + 1;
- fakeent->name[-1] = '/';
+ fakeent = alloc_alt_odb(get_object_directory());
}
fakeent->next = alt_odb_list;