alternates: provide helper for adding to alternates list
The submodule code wants to temporarily add an alternate object store to our in-memory alt_odb list, but does it manually. Let's provide a helper so it can reuse the code in link_alt_odb_entry(). While we're adding our new add_to_alternates_memory(), let's document add_to_alternates_file(), as the two are related. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
4ea82473aa
commit
a5b34d2152
11
sha1_file.c
11
sha1_file.c
@ -440,6 +440,17 @@ void add_to_alternates_file(const char *reference)
|
||||
free(alts);
|
||||
}
|
||||
|
||||
void add_to_alternates_memory(const char *reference)
|
||||
{
|
||||
/*
|
||||
* Make sure alternates are initialized, or else our entry may be
|
||||
* overwritten when they are.
|
||||
*/
|
||||
prepare_alt_odb();
|
||||
|
||||
link_alt_odb_entries(reference, strlen(reference), '\n', NULL, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the exact path an alternate is at and returns it. In case of
|
||||
* error NULL is returned and the human readable error is added to `err`
|
||||
|
Reference in New Issue
Block a user