mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 22:35:51 +00:00
Finish the References API
The following methods have been implemented: git_reference_packall git_reference_rename git_reference_delete The library now has full support for packed references, including partial and total writing. Internal documentation has been updated with the details. Signed-off-by: Vicent Marti <tanoku@gmail.com>
This commit is contained in:
parent
17cdf25208
commit
87d3acf45e
@ -187,6 +187,24 @@ GIT_EXTERN(int) git_reference_rename(git_reference *ref, const char *new_name);
|
|||||||
*/
|
*/
|
||||||
GIT_EXTERN(int) git_reference_delete(git_reference *ref);
|
GIT_EXTERN(int) git_reference_delete(git_reference *ref);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pack all the loose references in the repository
|
||||||
|
*
|
||||||
|
* This method will load into the cache all the loose
|
||||||
|
* references on the repository and update the
|
||||||
|
* `packed-refs` file with them.
|
||||||
|
*
|
||||||
|
* Once the `packed-refs` file has been written properly,
|
||||||
|
* the loose references will be removed from disk.
|
||||||
|
*
|
||||||
|
* WARNING: calling this method may invalidate any existing
|
||||||
|
* references previously loaded on the cache.
|
||||||
|
*
|
||||||
|
* @param repo Repository where the loose refs will be packed
|
||||||
|
* @return 0 on success; error code otherwise
|
||||||
|
*/
|
||||||
|
GIT_EXTERN(int) git_reference_packall(git_repository *repo);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
GIT_END_DECL
|
GIT_END_DECL
|
||||||
#endif
|
#endif
|
||||||
|
1299
src/refs.c
1299
src/refs.c
File diff suppressed because it is too large
Load Diff
@ -23,10 +23,8 @@ struct git_reference {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
git_hashtable *packed_refs;
|
git_hashtable *packfile;
|
||||||
git_hashtable *loose_refs;
|
git_hashtable *loose_cache;
|
||||||
|
|
||||||
unsigned pack_loaded:1;
|
|
||||||
} git_refcache;
|
} git_refcache;
|
||||||
|
|
||||||
|
|
||||||
|
@ -296,6 +296,13 @@ BEGIN_TEST("createref", create_new_object_id_ref)
|
|||||||
must_pass(gitfo_unlink(ref_path)); /* TODO: replace with git_reference_delete() when available */
|
must_pass(gitfo_unlink(ref_path)); /* TODO: replace with git_reference_delete() when available */
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
BEGIN_TEST("packrefs", create_packfile)
|
||||||
|
git_repository *repo;
|
||||||
|
must_pass(git_repository_open(&repo, REPOSITORY_FOLDER));
|
||||||
|
must_pass(git_reference_packall(repo));
|
||||||
|
git_repository_free(repo);
|
||||||
|
END_TEST
|
||||||
|
|
||||||
static int ensure_refname_normalized(int is_oid_ref, const char *input_refname, const char *expected_refname)
|
static int ensure_refname_normalized(int is_oid_ref, const char *input_refname, const char *expected_refname)
|
||||||
{
|
{
|
||||||
int error = GIT_SUCCESS;
|
int error = GIT_SUCCESS;
|
||||||
@ -494,6 +501,7 @@ git_testsuite *libgit2_suite_refs(void)
|
|||||||
ADD_TEST(suite, "normalizeref", normalize_object_id_ref);
|
ADD_TEST(suite, "normalizeref", normalize_object_id_ref);
|
||||||
ADD_TEST(suite, "normalizeref", normalize_symbolic_ref);
|
ADD_TEST(suite, "normalizeref", normalize_symbolic_ref);
|
||||||
ADD_TEST(suite, "normalizeref", jgit_tests);
|
ADD_TEST(suite, "normalizeref", jgit_tests);
|
||||||
|
//ADD_TEST(suite, "packrefs", create_packfile);
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user