mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
Merge pull request #7229 from weihanglo/fix
fix(transport): get oid_type on local transport
This commit is contained in:
@@ -41,6 +41,9 @@ typedef struct {
|
||||
git_vector refs;
|
||||
unsigned connected : 1,
|
||||
have_refs : 1;
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
git_oid_t oid_type;
|
||||
#endif
|
||||
} transport_local;
|
||||
|
||||
static void free_head(git_remote_head *head)
|
||||
@@ -231,6 +234,10 @@ static int local_connect(
|
||||
|
||||
t->repo = repo;
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
t->oid_type = repo->oid_type;
|
||||
#endif
|
||||
|
||||
if (store_refs(t) < 0)
|
||||
return -1;
|
||||
|
||||
@@ -267,7 +274,7 @@ static int local_oid_type(git_oid_t *out, git_transport *transport)
|
||||
{
|
||||
transport_local *t = (transport_local *)transport;
|
||||
|
||||
*out = t->repo->oid_type;
|
||||
*out = t->oid_type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -467,6 +467,26 @@ void test_network_remote_local__push_delete(void)
|
||||
cl_git_sandbox_cleanup();
|
||||
}
|
||||
|
||||
void test_network_remote_local__sha256_oid_type(void)
|
||||
{
|
||||
#ifndef GIT_EXPERIMENTAL_SHA256
|
||||
cl_skip();
|
||||
#else
|
||||
git_oid_t oid_type;
|
||||
|
||||
connect_to_local_repository(cl_fixture("testrepo_256.git"));
|
||||
|
||||
cl_git_pass(git_remote_oid_type(&oid_type, remote));
|
||||
cl_assert_equal_i(GIT_OID_SHA256, oid_type);
|
||||
|
||||
git_remote_disconnect(remote);
|
||||
|
||||
/* oid_type remains available after disconnect */
|
||||
cl_git_pass(git_remote_oid_type(&oid_type, remote));
|
||||
cl_assert_equal_i(GIT_OID_SHA256, oid_type);
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_network_remote_local__anonymous_remote_inmemory_repo(void)
|
||||
{
|
||||
git_repository *inmemory;
|
||||
|
||||
Reference in New Issue
Block a user