mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 02:16:21 +00:00
Deleting a branch deletes its reflog
This commit is contained in:
parent
1cc974ab62
commit
48110f67e4
@ -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:
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user