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
f8621dde
Commit
f8621dde
authored
Feb 05, 2014
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refs: factor out old value comparison
We will reuse this later for deletion.
parent
878fb66f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
14 deletions
+26
-14
src/refdb_fs.c
+26
-14
No files found.
src/refdb_fs.c
View file @
f8621dde
...
...
@@ -930,6 +930,30 @@ static bool should_write_reflog(git_repository *repo, const char *name)
return
0
;
}
static
int
cmp_old_ref
(
int
*
cmp
,
git_refdb_backend
*
backend
,
const
git_reference
*
ref
,
const
git_oid
*
old_id
,
const
char
*
old_target
)
{
int
error
=
0
;
git_reference
*
old_ref
=
NULL
;
*
cmp
=
0
;
if
(
old_id
||
old_target
)
{
if
((
error
=
refdb_fs_backend__lookup
(
&
old_ref
,
backend
,
ref
->
name
))
<
0
)
goto
out
;
}
if
(
old_id
&&
old_ref
->
type
==
GIT_REF_OID
)
*
cmp
=
git_oid_cmp
(
old_id
,
&
old_ref
->
target
.
oid
);
if
(
old_target
&&
old_ref
->
type
==
GIT_REF_SYMBOLIC
)
*
cmp
=
git__strcmp
(
old_target
,
old_ref
->
target
.
symbolic
);
out:
git_reference_free
(
old_ref
);
return
error
;
}
static
int
refdb_fs_backend__write
(
git_refdb_backend
*
_backend
,
const
git_reference
*
ref
,
...
...
@@ -954,20 +978,8 @@ static int refdb_fs_backend__write(
if
((
error
=
loose_lock
(
&
file
,
backend
,
ref
))
<
0
)
return
error
;
if
(
old_id
||
old_target
)
{
if
((
error
=
refdb_fs_backend__lookup
(
&
old_ref
,
_backend
,
ref
->
name
))
<
0
)
goto
on_error
;
}
if
(
old_id
&&
old_ref
->
type
==
GIT_REF_OID
)
{
cmp
=
git_oid_cmp
(
old_id
,
&
old_ref
->
target
.
oid
);
git_reference_free
(
old_ref
);
}
if
(
old_target
&&
old_ref
->
type
==
GIT_REF_SYMBOLIC
)
{
cmp
=
git__strcmp
(
old_target
,
old_ref
->
target
.
symbolic
);
git_reference_free
(
old_ref
);
}
if
((
error
=
cmp_old_ref
(
&
cmp
,
_backend
,
ref
,
old_id
,
old_target
))
<
0
)
goto
on_error
;
if
(
cmp
)
{
giterr_set
(
GITERR_REFERENCE
,
"old reference value does not match"
);
...
...
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