summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2008-04-17 19:32:30 -0400
committerJunio C Hamano <gitster@pobox.com>2008-05-04 17:41:44 -0700
commitbef70b22ba63d71c1ae2e070e64ff9863ea1ad14 (patch)
treec8f02795dc1d86cb5459d034604896d8b3a76ac8 /sha1_file.c
parentea3cd5c7c63fadacd66c364ae4b8c6d01e5809b1 (diff)
downloadgit-bef70b22ba63d71c1ae2e070e64ff9863ea1ad14.tar.gz
Add a library function to add an alternate to the alternates file
This is in the core so that, if the alternates file has already been read, the addition can be parsed and put into effect for the current process. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 3516777bc7..d21e23b464 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -380,6 +380,18 @@ static void read_info_alternates(const char * relative_base, int depth)
munmap(map, mapsz);
}
+void add_to_alternates_file(const char *reference)
+{
+ struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
+ int fd = hold_lock_file_for_append(lock, git_path("objects/info/alternates"), 1);
+ char *alt = mkpath("%s/objects\n", reference);
+ write_or_die(fd, alt, strlen(alt));
+ if (commit_lock_file(lock))
+ die("could not close alternates file");
+ if (alt_odb_tail)
+ link_alt_odb_entries(alt, alt + strlen(alt), '\n', NULL, 0);
+}
+
void prepare_alt_odb(void)
{
const char *alt;