Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
fc4c00b2
Unverified
Commit
fc4c00b2
authored
May 06, 2023
by
Edward Thomson
Committed by
GitHub
May 06, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6556 from libgit2/ethomson/wrap_odb
Support SHA256 in git_repository_wrap_odb
parents
30917576
161d8a12
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
9 deletions
+62
-9
include/git2/repository.h
+12
-2
src/libgit2/repository.c
+21
-3
src/libgit2/repository.h
+5
-0
tests/libgit2/odb/backend/loose.c
+21
-2
tests/libgit2/odb/backend/mempack.c
+1
-1
tests/libgit2/refs/iterator.c
+2
-1
No files found.
include/git2/repository.h
View file @
fc4c00b2
...
@@ -56,9 +56,19 @@ GIT_EXTERN(int) git_repository_open_from_worktree(git_repository **out, git_work
...
@@ -56,9 +56,19 @@ GIT_EXTERN(int) git_repository_open_from_worktree(git_repository **out, git_work
*
*
* @param out pointer to the repo
* @param out pointer to the repo
* @param odb the object database to wrap
* @param odb the object database to wrap
* @param oid_type the oid type of the object database
* @return 0 or an error code
* @return 0 or an error code
*/
*/
GIT_EXTERN
(
int
)
git_repository_wrap_odb
(
git_repository
**
out
,
git_odb
*
odb
);
#ifdef GIT_EXPERIMENTAL_SHA256
GIT_EXTERN
(
int
)
git_repository_wrap_odb
(
git_repository
**
out
,
git_odb
*
odb
,
git_oid_t
oid_type
);
#else
GIT_EXTERN
(
int
)
git_repository_wrap_odb
(
git_repository
**
out
,
git_odb
*
odb
);
#endif
/**
/**
* Look for a git repository and copy its path in the given buffer.
* Look for a git repository and copy its path in the given buffer.
...
@@ -536,7 +546,7 @@ GIT_EXTERN(const char *) git_repository_workdir(const git_repository *repo);
...
@@ -536,7 +546,7 @@ GIT_EXTERN(const char *) git_repository_workdir(const git_repository *repo);
/**
/**
* Get the path of the shared common directory for this repository.
* Get the path of the shared common directory for this repository.
*
*
* If the repository is bare, it is the root directory for the repository.
* If the repository is bare, it is the root directory for the repository.
* If the repository is a worktree, it is the parent repo's gitdir.
* If the repository is a worktree, it is the parent repo's gitdir.
* Otherwise, it is the gitdir.
* Otherwise, it is the gitdir.
...
...
src/libgit2/repository.c
View file @
fc4c00b2
...
@@ -1145,21 +1145,39 @@ out:
...
@@ -1145,21 +1145,39 @@ out:
return
err
;
return
err
;
}
}
int
git_repository_wrap_odb
(
git_repository
**
repo_out
,
git_odb
*
odb
)
int
git_repository__wrap_odb
(
git_repository
**
out
,
git_odb
*
odb
,
git_oid_t
oid_type
)
{
{
git_repository
*
repo
;
git_repository
*
repo
;
repo
=
repository_alloc
();
repo
=
repository_alloc
();
GIT_ERROR_CHECK_ALLOC
(
repo
);
GIT_ERROR_CHECK_ALLOC
(
repo
);
repo
->
oid_type
=
GIT_OID_DEFAULT
;
repo
->
oid_type
=
oid_type
;
git_repository_set_odb
(
repo
,
odb
);
git_repository_set_odb
(
repo
,
odb
);
*
repo_
out
=
repo
;
*
out
=
repo
;
return
0
;
return
0
;
}
}
#ifdef GIT_EXPERIMENTAL_SHA256
int
git_repository_wrap_odb
(
git_repository
**
out
,
git_odb
*
odb
,
git_oid_t
oid_type
)
{
return
git_repository__wrap_odb
(
out
,
odb
,
oid_type
);
}
#else
int
git_repository_wrap_odb
(
git_repository
**
out
,
git_odb
*
odb
)
{
return
git_repository__wrap_odb
(
out
,
odb
,
GIT_OID_DEFAULT
);
}
#endif
int
git_repository_discover
(
int
git_repository_discover
(
git_buf
*
out
,
git_buf
*
out
,
const
char
*
start_path
,
const
char
*
start_path
,
...
...
src/libgit2/repository.h
View file @
fc4c00b2
...
@@ -190,6 +190,11 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo);
...
@@ -190,6 +190,11 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo);
int
git_repository_refdb__weakptr
(
git_refdb
**
out
,
git_repository
*
repo
);
int
git_repository_refdb__weakptr
(
git_refdb
**
out
,
git_repository
*
repo
);
int
git_repository_index__weakptr
(
git_index
**
out
,
git_repository
*
repo
);
int
git_repository_index__weakptr
(
git_index
**
out
,
git_repository
*
repo
);
int
git_repository__wrap_odb
(
git_repository
**
out
,
git_odb
*
odb
,
git_oid_t
oid_type
);
/*
/*
* Configuration map cache
* Configuration map cache
*
*
...
...
tests/libgit2/odb/backend/loose.c
View file @
fc4c00b2
...
@@ -21,7 +21,7 @@ void test_odb_backend_loose__initialize(void)
...
@@ -21,7 +21,7 @@ void test_odb_backend_loose__initialize(void)
cl_git_pass
(
git_odb__new
(
&
_odb
,
NULL
));
cl_git_pass
(
git_odb__new
(
&
_odb
,
NULL
));
cl_git_pass
(
git_odb_add_backend
(
_odb
,
backend
,
10
));
cl_git_pass
(
git_odb_add_backend
(
_odb
,
backend
,
10
));
cl_git_pass
(
git_repository_
wrap_odb
(
&
_repo
,
_odb
));
cl_git_pass
(
git_repository_
_wrap_odb
(
&
_repo
,
_odb
,
GIT_OID_SHA1
));
}
}
void
test_odb_backend_loose__cleanup
(
void
)
void
test_odb_backend_loose__cleanup
(
void
)
...
@@ -32,7 +32,7 @@ void test_odb_backend_loose__cleanup(void)
...
@@ -32,7 +32,7 @@ void test_odb_backend_loose__cleanup(void)
cl_fixture_cleanup
(
"testrepo.git"
);
cl_fixture_cleanup
(
"testrepo.git"
);
}
}
void
test_odb_backend_loose__read
(
void
)
void
test_odb_backend_loose__read
_from_odb
(
void
)
{
{
git_oid
oid
;
git_oid
oid
;
git_odb_object
*
obj
;
git_odb_object
*
obj
;
...
@@ -40,4 +40,23 @@ void test_odb_backend_loose__read(void)
...
@@ -40,4 +40,23 @@ void test_odb_backend_loose__read(void)
cl_git_pass
(
git_oid__fromstr
(
&
oid
,
"1385f264afb75a56a5bec74243be9b367ba4ca08"
,
GIT_OID_SHA1
));
cl_git_pass
(
git_oid__fromstr
(
&
oid
,
"1385f264afb75a56a5bec74243be9b367ba4ca08"
,
GIT_OID_SHA1
));
cl_git_pass
(
git_odb_read
(
&
obj
,
_odb
,
&
oid
));
cl_git_pass
(
git_odb_read
(
&
obj
,
_odb
,
&
oid
));
git_odb_object_free
(
obj
);
git_odb_object_free
(
obj
);
cl_git_pass
(
git_oid__fromstr
(
&
oid
,
"fd093bff70906175335656e6ce6ae05783708765"
,
GIT_OID_SHA1
));
cl_git_pass
(
git_odb_read
(
&
obj
,
_odb
,
&
oid
));
git_odb_object_free
(
obj
);
}
void
test_odb_backend_loose__read_from_repo
(
void
)
{
git_oid
oid
;
git_blob
*
blob
;
git_tree
*
tree
;
cl_git_pass
(
git_oid__fromstr
(
&
oid
,
"1385f264afb75a56a5bec74243be9b367ba4ca08"
,
GIT_OID_SHA1
));
cl_git_pass
(
git_blob_lookup
(
&
blob
,
_repo
,
&
oid
));
git_blob_free
(
blob
);
cl_git_pass
(
git_oid__fromstr
(
&
oid
,
"fd093bff70906175335656e6ce6ae05783708765"
,
GIT_OID_SHA1
));
cl_git_pass
(
git_tree_lookup
(
&
tree
,
_repo
,
&
oid
));
git_tree_free
(
tree
);
}
}
tests/libgit2/odb/backend/mempack.c
View file @
fc4c00b2
...
@@ -16,7 +16,7 @@ void test_odb_backend_mempack__initialize(void)
...
@@ -16,7 +16,7 @@ void test_odb_backend_mempack__initialize(void)
cl_git_pass
(
git_mempack_new
(
&
backend
));
cl_git_pass
(
git_mempack_new
(
&
backend
));
cl_git_pass
(
git_odb__new
(
&
_odb
,
NULL
));
cl_git_pass
(
git_odb__new
(
&
_odb
,
NULL
));
cl_git_pass
(
git_odb_add_backend
(
_odb
,
backend
,
10
));
cl_git_pass
(
git_odb_add_backend
(
_odb
,
backend
,
10
));
cl_git_pass
(
git_repository_
wrap_odb
(
&
_repo
,
_odb
));
cl_git_pass
(
git_repository_
_wrap_odb
(
&
_repo
,
_odb
,
GIT_OID_SHA1
));
}
}
void
test_odb_backend_mempack__cleanup
(
void
)
void
test_odb_backend_mempack__cleanup
(
void
)
...
...
tests/libgit2/refs/iterator.c
View file @
fc4c00b2
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include "refs.h"
#include "refs.h"
#include "vector.h"
#include "vector.h"
#include "odb.h"
#include "odb.h"
#include "repository.h"
static
git_repository
*
repo
;
static
git_repository
*
repo
;
...
@@ -128,7 +129,7 @@ void test_refs_iterator__empty(void)
...
@@ -128,7 +129,7 @@ void test_refs_iterator__empty(void)
git_repository
*
empty
;
git_repository
*
empty
;
cl_git_pass
(
git_odb__new
(
&
odb
,
NULL
));
cl_git_pass
(
git_odb__new
(
&
odb
,
NULL
));
cl_git_pass
(
git_repository_
wrap_odb
(
&
empty
,
odb
));
cl_git_pass
(
git_repository_
_wrap_odb
(
&
empty
,
odb
,
GIT_OID_SHA1
));
cl_git_pass
(
git_reference_iterator_new
(
&
iter
,
empty
));
cl_git_pass
(
git_reference_iterator_new
(
&
iter
,
empty
));
cl_assert_equal_i
(
GIT_ITEROVER
,
git_reference_next
(
&
ref
,
iter
));
cl_assert_equal_i
(
GIT_ITEROVER
,
git_reference_next
(
&
ref
,
iter
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment