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
58944388
Commit
58944388
authored
May 16, 2021
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'zero_oid_in_old'
Manually merging #5842
parents
be95f684
cf323cb9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletions
+23
-1
include/git2/refs.h
+3
-0
src/refdb_fs.c
+4
-1
tests/refs/races.c
+16
-0
No files found.
include/git2/refs.h
View file @
58944388
...
...
@@ -97,6 +97,9 @@ GIT_EXTERN(int) git_reference_dwim(git_reference **out, git_repository *repo, co
* of updating does not match the one passed through `current_value`
* (i.e. if the ref has changed since the user read it).
*
* If `current_value` is all zeros, this function will return GIT_EMODIFIED
* if the ref already exists.
*
* @param out Pointer to the newly created reference
* @param repo Repository where that reference will live
* @param name The name of the reference
...
...
src/refdb_fs.c
View file @
58944388
...
...
@@ -1173,8 +1173,11 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
if
(
!
old_id
&&
!
old_target
)
return
0
;
if
((
error
=
refdb_fs_backend__lookup
(
&
old_ref
,
backend
,
name
))
<
0
)
if
((
error
=
refdb_fs_backend__lookup
(
&
old_ref
,
backend
,
name
))
<
0
)
{
if
(
error
==
GIT_ENOTFOUND
&&
old_id
&&
git_oid_is_zero
(
old_id
))
return
0
;
goto
out
;
}
/* If the types don't match, there's no way the values do */
if
(
old_id
&&
old_ref
->
type
!=
GIT_REFERENCE_DIRECT
)
{
...
...
tests/refs/races.c
View file @
58944388
...
...
@@ -22,6 +22,22 @@ void test_refs_races__cleanup(void)
cl_git_sandbox_cleanup
();
}
void
test_refs_races__create_matching_zero_old
(
void
)
{
git_reference
*
ref
;
git_oid
id
,
zero_id
;
git_oid_fromstr
(
&
id
,
commit_id
);
git_oid_fromstr
(
&
zero_id
,
"0000000000000000000000000000000000000000"
);
cl_git_fail
(
git_reference_create_matching
(
&
ref
,
g_repo
,
refname
,
&
id
,
1
,
&
zero_id
,
NULL
));
cl_git_pass
(
git_reference_create_matching
(
&
ref
,
g_repo
,
other_refname
,
&
id
,
1
,
&
zero_id
,
NULL
));
cl_git_fail
(
git_reference_create_matching
(
&
ref
,
g_repo
,
other_refname
,
&
id
,
1
,
&
zero_id
,
NULL
));
git_reference_free
(
ref
);
}
void
test_refs_races__create_matching
(
void
)
{
git_reference
*
ref
,
*
ref2
,
*
ref3
;
...
...
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