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
91dad181
Commit
91dad181
authored
Jul 24, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3305 from libgit2/cmn/reflog-del-backend
refdb: delete a ref's reflog upon deletion
parents
14e805a2
01d0c02d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
14 deletions
+17
-14
CHANGELOG.md
+4
-0
include/git2/sys/refdb_backend.h
+3
-2
src/branch.c
+1
-12
src/refdb_fs.c
+7
-0
tests/refs/branches/delete.c
+2
-0
No files found.
CHANGELOG.md
View file @
91dad181
...
...
@@ -15,6 +15,10 @@ v0.23 + 1
*
`git_cert`
descendent types now have a proper
`parent`
member
*
It is the responsibility fo the refdb backend to decide what to do
with the reflog on ref deletion. The file-based backend must delete
it, a database-backed one may wish to archive it.
v0.23
------
...
...
include/git2/sys/refdb_backend.h
View file @
91dad181
...
...
@@ -103,8 +103,9 @@ struct git_refdb_backend {
const
git_signature
*
who
,
const
char
*
message
);
/**
* Deletes the given reference from the refdb. A refdb implementation
* must provide this function.
* Deletes the given reference (and if necessary its reflog)
* from the refdb. A refdb implementation must provide this
* function.
*/
int
(
*
del
)(
git_refdb_backend
*
backend
,
const
char
*
ref_name
,
const
git_oid
*
old_id
,
const
char
*
old_target
);
...
...
src/branch.c
View file @
91dad181
...
...
@@ -155,18 +155,7 @@ int git_branch_delete(git_reference *branch)
git_reference_owner
(
branch
),
git_buf_cstr
(
&
config_section
),
NULL
)
<
0
)
goto
on_error
;
if
(
git_reference_delete
(
branch
)
<
0
)
goto
on_error
;
if
((
error
=
git_reflog_delete
(
git_reference_owner
(
branch
),
git_reference_name
(
branch
)))
<
0
)
{
if
(
error
==
GIT_ENOTFOUND
)
{
giterr_clear
();
error
=
0
;
}
goto
on_error
;
}
error
=
0
;
error
=
git_reference_delete
(
branch
);
on_error:
git_buf_free
(
&
config_section
);
...
...
src/refdb_fs.c
View file @
91dad181
...
...
@@ -63,6 +63,8 @@ typedef struct refdb_fs_backend {
uint32_t
direach_flags
;
}
refdb_fs_backend
;
static
int
refdb_reflog_fs__delete
(
git_refdb_backend
*
_backend
,
const
char
*
name
);
static
int
packref_cmp
(
const
void
*
a_
,
const
void
*
b_
)
{
const
struct
packref
*
a
=
a_
,
*
b
=
b_
;
...
...
@@ -1217,6 +1219,11 @@ static int refdb_fs_backend__delete(
if
((
error
=
loose_lock
(
&
file
,
backend
,
ref_name
))
<
0
)
return
error
;
if
((
error
=
refdb_reflog_fs__delete
(
_backend
,
ref_name
))
<
0
)
{
git_filebuf_cleanup
(
&
file
);
return
error
;
}
return
refdb_fs_backend__delete_tail
(
_backend
,
&
file
,
ref_name
,
old_id
,
old_target
);
}
...
...
tests/refs/branches/delete.c
View file @
91dad181
...
...
@@ -132,6 +132,8 @@ void test_refs_branches_delete__removes_reflog(void)
cl_git_pass
(
git_branch_delete
(
branch
));
git_reference_free
(
branch
);
cl_assert_equal_i
(
false
,
git_reference_has_log
(
repo
,
"refs/heads/track-local"
));
/* Reading a nonexistant reflog creates it, but it should be empty */
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
"refs/heads/track-local"
));
cl_assert_equal_i
(
0
,
git_reflog_entrycount
(
log
));
...
...
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