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
4795807a
Commit
4795807a
authored
Apr 23, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #637 from nulltoken/issue/odb-refcount
Fix git_repository_set_odb() refcount issue
parents
5c9a794d
baf861a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
src/repository.c
+1
-0
tests-clar/repo/getters.c
+16
-0
tests-clar/repo/setters.c
+21
-0
No files found.
src/repository.c
View file @
4795807a
...
...
@@ -552,6 +552,7 @@ void git_repository_set_odb(git_repository *repo, git_odb *odb)
repo
->
_odb
=
odb
;
GIT_REFCOUNT_OWN
(
repo
->
_odb
,
repo
);
GIT_REFCOUNT_INC
(
odb
);
}
int
git_repository_index__weakptr
(
git_index
**
out
,
git_repository
*
repo
)
...
...
tests-clar/repo/getters.c
View file @
4795807a
...
...
@@ -68,3 +68,19 @@ void test_repo_getters__head_orphan(void)
git_reference_free
(
ref
);
git_repository_free
(
repo
);
}
void
test_repo_getters__retrieving_the_odb_honors_the_refcount
(
void
)
{
git_odb
*
odb
;
git_repository
*
repo
;
cl_git_pass
(
git_repository_open
(
&
repo
,
"testrepo.git"
));
cl_git_pass
(
git_repository_odb
(
&
odb
,
repo
));
cl_assert
(((
git_refcount
*
)
odb
)
->
refcount
==
2
);
git_repository_free
(
repo
);
cl_assert
(((
git_refcount
*
)
odb
)
->
refcount
==
1
);
git_odb_free
(
odb
);
}
tests-clar/repo/setters.c
View file @
4795807a
...
...
@@ -57,3 +57,24 @@ void test_repo_setters__setting_a_new_index_on_a_repo_which_has_already_loaded_o
*/
repo
=
NULL
;
}
void
test_repo_setters__setting_a_new_odb_on_a_repo_which_already_loaded_one_properly_honors_the_refcount
(
void
)
{
git_odb
*
new_odb
;
cl_git_pass
(
git_odb_open
(
&
new_odb
,
"./testrepo.git/objects"
));
cl_assert
(((
git_refcount
*
)
new_odb
)
->
refcount
==
1
);
git_repository_set_odb
(
repo
,
new_odb
);
cl_assert
(((
git_refcount
*
)
new_odb
)
->
refcount
==
2
);
git_repository_free
(
repo
);
cl_assert
(((
git_refcount
*
)
new_odb
)
->
refcount
==
1
);
git_odb_free
(
new_odb
);
/*
* Ensure the cleanup method won't try to free the repo as it's already been taken care of
*/
repo
=
NULL
;
}
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