diff options
| author | Patrick Steinhardt <ps@pks.im> | 2015-11-06 12:33:59 +0100 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2017-02-13 11:05:57 +0100 |
| commit | 143e539fd0e9b83c6a3a369d5baf508ccb51697b (patch) | |
| tree | f38a69f6e65cfdfd4c37d543cd6f18330c2b602d /tests/worktree/refs.c | |
| parent | e3acd37b70dc6d8f1ff256b99a26b4e0f13701ef (diff) | |
| download | libgit2-143e539fd0e9b83c6a3a369d5baf508ccb51697b.tar.gz | |
branch: restrict branch deletion for worktrees
Restrict the ability to delete branches that are checked out in
any linked repository.
Diffstat (limited to 'tests/worktree/refs.c')
| -rw-r--r-- | tests/worktree/refs.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/worktree/refs.c b/tests/worktree/refs.c index e08e55372..38f612713 100644 --- a/tests/worktree/refs.c +++ b/tests/worktree/refs.c @@ -1,4 +1,5 @@ #include "clar_libgit2.h" +#include "worktree.h" #include "worktree_helpers.h" #define COMMON_REPO "testrepo" @@ -66,3 +67,29 @@ void test_worktree_refs__read_head(void) git_reference_free(head); } + +void test_worktree_refs__delete_fails_for_checked_out_branch(void) +{ + git_reference *branch; + + cl_git_pass(git_branch_lookup(&branch, fixture.repo, + "testrepo-worktree", GIT_BRANCH_LOCAL)); + cl_git_fail(git_branch_delete(branch)); + + git_reference_free(branch); +} + +void test_worktree_refs__delete_succeeds_after_pruning_worktree(void) +{ + git_reference *branch; + git_worktree *worktree; + + cl_git_pass(git_worktree_lookup(&worktree, fixture.repo, fixture.worktreename)); + cl_git_pass(git_worktree_prune(worktree, GIT_WORKTREE_PRUNE_VALID)); + git_worktree_free(worktree); + + cl_git_pass(git_branch_lookup(&branch, fixture.repo, + "testrepo-worktree", GIT_BRANCH_LOCAL)); + cl_git_pass(git_branch_delete(branch)); + git_reference_free(branch); +} |
