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
1fd26760
Unverified
Commit
1fd26760
authored
Apr 17, 2018
by
Edward Thomson
Committed by
GitHub
Apr 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4618 from tiennou/fix/pwned-references
refs: preserve the owning refdb when duping reference
parents
d7f413c0
2dc54855
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
0 deletions
+10
-0
src/refs.c
+3
-0
src/refs.h
+4
-0
tests/refs/dup.c
+2
-0
tests/worktree/repository.c
+1
-0
No files found.
src/refs.c
View file @
1fd26760
...
...
@@ -115,6 +115,9 @@ int git_reference_dup(git_reference **dest, git_reference *source)
GITERR_CHECK_ALLOC
(
*
dest
);
(
*
dest
)
->
db
=
source
->
db
;
GIT_REFCOUNT_INC
((
*
dest
)
->
db
);
return
0
;
}
...
...
src/refs.h
View file @
1fd26760
...
...
@@ -116,6 +116,10 @@ int git_reference_lookup_resolved(
* with the given name pointing to the reference pointed to by
* the file. If it is not a symbolic reference, it will return
* the resolved reference.
*
* Note that because the refdb is not involved for symbolic references, they
* won't be owned, hence you should either not make the returned reference
* 'externally visible', or perform the lookup before returning it to the user.
*/
int
git_reference__read_head
(
git_reference
**
out
,
...
...
tests/refs/dup.c
View file @
1fd26760
...
...
@@ -21,6 +21,7 @@ void test_refs_dup__direct(void)
cl_git_pass
(
git_reference_dup
(
&
b
,
a
));
cl_assert
(
git_reference_cmp
(
a
,
b
)
==
0
);
cl_assert
(
git_reference_owner
(
b
)
==
g_repo
);
git_reference_free
(
b
);
git_reference_free
(
a
);
...
...
@@ -34,6 +35,7 @@ void test_refs_dup__symbolic(void)
cl_git_pass
(
git_reference_dup
(
&
b
,
a
));
cl_assert
(
git_reference_cmp
(
a
,
b
)
==
0
);
cl_assert
(
git_reference_owner
(
b
)
==
g_repo
);
git_reference_free
(
b
);
git_reference_free
(
a
);
...
...
tests/worktree/repository.c
View file @
1fd26760
...
...
@@ -27,6 +27,7 @@ void test_worktree_repository__head(void)
cl_git_pass
(
git_reference_lookup
(
&
ref
,
fixture
.
repo
,
"refs/heads/testrepo-worktree"
));
cl_git_pass
(
git_repository_head_for_worktree
(
&
head
,
fixture
.
repo
,
"testrepo-worktree"
));
cl_assert
(
git_reference_cmp
(
ref
,
head
)
==
0
);
cl_assert
(
git_reference_owner
(
ref
)
==
fixture
.
repo
);
git_reference_free
(
ref
);
git_reference_free
(
head
);
...
...
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