mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-11 11:15:07 +00:00
odb: Add git_odb_add_disk_alternate
Loads a disk alternate by path to the ODB. Mimics the `GIT_ALTERNATE_OBJECT_DIRECTORIES` shell var.
This commit is contained in:
parent
64c5112188
commit
9507a434c6
@ -88,6 +88,23 @@ GIT_EXTERN(int) git_odb_add_backend(git_odb *odb, git_odb_backend *backend, int
|
|||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
|
GIT_EXTERN(int) git_odb_add_alternate(git_odb *odb, git_odb_backend *backend, int priority);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an on-disk alternate to an existing Object DB.
|
||||||
|
*
|
||||||
|
* Note that the added path must point to an `objects`, not
|
||||||
|
* to a full repository, to use it as an alternate store.
|
||||||
|
*
|
||||||
|
* Alternate backends are always checked for objects *after*
|
||||||
|
* all the main backends have been exhausted.
|
||||||
|
*
|
||||||
|
* Writing is disabled on alternate backends.
|
||||||
|
*
|
||||||
|
* @param odb database to add the backend to
|
||||||
|
* @param path path to the objects folder for the alternate
|
||||||
|
* @return 0 on success; error code otherwise
|
||||||
|
*/
|
||||||
|
GIT_EXTERN(int) git_odb_add_disk_alternate(git_odb *odb, const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close an open object database.
|
* Close an open object database.
|
||||||
*
|
*
|
||||||
|
@ -470,6 +470,11 @@ static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int git_odb_add_disk_alternate(git_odb *odb, const char *path)
|
||||||
|
{
|
||||||
|
return add_default_backends(odb, path, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int git_odb_open(git_odb **out, const char *objects_dir)
|
int git_odb_open(git_odb **out, const char *objects_dir)
|
||||||
{
|
{
|
||||||
git_odb *db;
|
git_odb *db;
|
||||||
@ -481,8 +486,7 @@ int git_odb_open(git_odb **out, const char *objects_dir)
|
|||||||
if (git_odb_new(&db) < 0)
|
if (git_odb_new(&db) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (add_default_backends(db, objects_dir, 0, 0) < 0)
|
if (add_default_backends(db, objects_dir, 0, 0) < 0) {
|
||||||
{
|
|
||||||
git_odb_free(db);
|
git_odb_free(db);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user