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
54e4d0f2
Commit
54e4d0f2
authored
Apr 18, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #629 from nulltoken/issue/index-refcount
Index refcount issue
parents
e8c3774f
c1aefb35
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletions
+23
-1
src/repository.c
+1
-0
tests-clar/repo/open.c
+0
-1
tests-clar/repo/setters.c
+22
-0
No files found.
src/repository.c
View file @
54e4d0f2
...
...
@@ -595,6 +595,7 @@ void git_repository_set_index(git_repository *repo, git_index *index)
repo
->
_index
=
index
;
GIT_REFCOUNT_OWN
(
repo
->
_index
,
repo
);
GIT_REFCOUNT_INC
(
index
);
}
static
int
check_repositoryformatversion
(
git_repository
*
repo
)
...
...
tests-clar/repo/open.c
View file @
54e4d0f2
...
...
@@ -234,7 +234,6 @@ void test_repo_open__win32_path(void)
#ifdef GIT_WIN32
git_repository
*
repo
=
cl_git_sandbox_init
(
"empty_standard_repo"
),
*
repo2
;
git_buf
winpath
=
GIT_BUF_INIT
;
char
*
src
,
*
tgt
;
static
const
char
*
repo_path
=
"empty_standard_repo/.git/"
;
static
const
char
*
repo_wd
=
"empty_standard_repo/"
;
...
...
tests-clar/repo/setters.c
View file @
54e4d0f2
#include "clar_libgit2.h"
#include "buffer.h"
#include "posix.h"
#include "util.h"
static
git_repository
*
repo
;
...
...
@@ -35,3 +36,24 @@ void test_repo_setters__setting_a_workdir_prettifies_its_path(void)
cl_assert
(
git__suffixcmp
(
git_repository_workdir
(
repo
),
"/"
)
==
0
);
}
void
test_repo_setters__setting_a_new_index_on_a_repo_which_has_already_loaded_one_properly_honors_the_refcount
(
void
)
{
git_index
*
new_index
;
cl_git_pass
(
git_index_open
(
&
new_index
,
"./my-index"
));
cl_assert
(((
git_refcount
*
)
new_index
)
->
refcount
==
1
);
git_repository_set_index
(
repo
,
new_index
);
cl_assert
(((
git_refcount
*
)
new_index
)
->
refcount
==
2
);
git_repository_free
(
repo
);
cl_assert
(((
git_refcount
*
)
new_index
)
->
refcount
==
1
);
git_index_free
(
new_index
);
/*
* 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