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
48110f67
Commit
48110f67
authored
Jan 28, 2014
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deleting a branch deletes its reflog
parent
1cc974ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
20 deletions
+29
-20
src/branch.c
+3
-0
tests/refs/branches/create.c
+0
-20
tests/refs/branches/delete.c
+26
-0
No files found.
src/branch.c
View file @
48110f67
...
...
@@ -111,6 +111,9 @@ int git_branch_delete(git_reference *branch)
if
(
git_reference_delete
(
branch
)
<
0
)
goto
on_error
;
if
(
git_reflog_delete
(
git_reference_owner
(
branch
),
git_reference_name
(
branch
))
<
0
)
goto
on_error
;
error
=
0
;
on_error:
...
...
tests/refs/branches/create.c
View file @
48110f67
...
...
@@ -87,23 +87,3 @@ void test_refs_branches_create__creation_creates_new_reflog(void)
entry
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
"create!"
,
git_reflog_entry_message
(
entry
));
}
void
test_refs_branches_create__recreation_updates_existing_reflog
(
void
)
{
git_reflog
*
log
;
const
git_reflog_entry
*
entry1
,
*
entry2
;
retrieve_known_commit
(
&
target
,
repo
);
cl_git_pass
(
git_branch_create
(
&
branch
,
repo
,
NEW_BRANCH_NAME
,
target
,
false
,
NULL
,
"Create 1"
));
cl_git_pass
(
git_branch_delete
(
branch
));
cl_git_pass
(
git_branch_create
(
&
branch
,
repo
,
NEW_BRANCH_NAME
,
target
,
false
,
NULL
,
"Create 2"
));
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
"refs/heads/"
NEW_BRANCH_NAME
));
cl_assert_equal_i
(
2
,
git_reflog_entrycount
(
log
));
entry1
=
git_reflog_entry_byindex
(
log
,
1
);
entry2
=
git_reflog_entry_byindex
(
log
,
0
);
cl_assert_equal_s
(
"Create 1"
,
git_reflog_entry_message
(
entry1
));
cl_assert_equal_s
(
"Create 2"
,
git_reflog_entry_message
(
entry2
));
}
tests/refs/branches/delete.c
View file @
48110f67
...
...
@@ -115,3 +115,29 @@ void test_refs_branches_delete__deleting_a_branch_removes_related_configuration_
assert_config_entry_existence
(
repo
,
"branch.track-local.remote"
,
false
);
assert_config_entry_existence
(
repo
,
"branch.track-local.merge"
,
false
);
}
void
test_refs_branches_delete__removes_reflog
(
void
)
{
git_reference
*
branch
;
git_reflog
*
log
;
git_oid
oidzero
=
{{
0
}};
git_signature
*
sig
;
/* Ensure the reflog has at least one entry */
cl_git_pass
(
git_signature_now
(
&
sig
,
"Me"
,
"user@example.com"
));
cl_git_pass
(
git_reflog_read
(
&
log
,
repo
,
"refs/heads/track-local"
));
cl_git_pass
(
git_reflog_append
(
log
,
&
oidzero
,
sig
,
"message"
));
cl_assert
(
git_reflog_entrycount
(
log
)
>
0
);
git_signature_free
(
sig
);
git_reflog_free
(
log
);
cl_git_pass
(
git_branch_lookup
(
&
branch
,
repo
,
"track-local"
,
GIT_BRANCH_LOCAL
));
cl_git_pass
(
git_branch_delete
(
branch
));
git_reference_free
(
branch
);
/* 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
));
git_reflog_free
(
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