branch: drop git_branch_list()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
diff --git a/include/git2/branch.h b/include/git2/branch.h
index f2239a2..8884df1 100644
--- a/include/git2/branch.h
+++ b/include/git2/branch.h
@@ -72,30 +72,6 @@ GIT_EXTERN(int) git_branch_delete(
git_branch_t branch_type);
/**
- * Fill a list with all the branches in the Repository
- *
- * The string array will be filled with the names of the
- * matching branches; these values are owned by the user and
- * should be free'd manually when no longer needed, using
- * `git_strarray_free`.
- *
- * @param branch_names Pointer to a git_strarray structure
- * where the branch names will be stored.
- *
- * @param repo Repository where to find the branches.
- *
- * @param list_flags Filtering flags for the branch
- * listing. Valid values are GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE
- * or a combination of the two.
- *
- * @return 0 or an error code.
- */
-GIT_EXTERN(int) git_branch_list(
- git_strarray *branch_names,
- git_repository *repo,
- unsigned int list_flags);
-
-/**
* Loop over all the branches and issue a callback for each one.
*
* @param repo Repository where to find the branches.
diff --git a/src/branch.c b/src/branch.c
index 94d9a95..671e420 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -141,49 +141,6 @@ on_error:
}
typedef struct {
- git_vector *branchlist;
- unsigned int branch_type;
-} branch_filter_data;
-
-static int branch_list_cb(const char *branch_name, void *payload)
-{
- branch_filter_data *filter = (branch_filter_data *)payload;
-
- if (filter->branch_type & GIT_BRANCH_LOCAL && git__prefixcmp(branch_name, GIT_REFS_HEADS_DIR) == 0) {
- return git_vector_insert(filter->branchlist, git__strdup(branch_name +strlen(GIT_REFS_HEADS_DIR)));
- } else if (filter->branch_type & GIT_BRANCH_REMOTE && git__prefixcmp(branch_name, GIT_REFS_REMOTES_DIR) == 0) {
- return git_vector_insert(filter->branchlist, git__strdup(branch_name+strlen(GIT_REFS_DIR)));
- }
-
- return 0;
-}
-
-int git_branch_list(git_strarray *branch_names, git_repository *repo, unsigned int list_flags)
-{
- int error;
- branch_filter_data filter;
- git_vector branchlist;
-
- assert(branch_names && repo);
-
- if (git_vector_init(&branchlist, 8, NULL) < 0)
- return -1;
-
- filter.branchlist = &branchlist;
- filter.branch_type = list_flags;
-
- error = git_reference_foreach(repo, GIT_REF_LISTALL, &branch_list_cb, (void *)&filter);
- if (error < 0) {
- git_vector_free(&branchlist);
- return -1;
- }
-
- branch_names->strings = (char **)branchlist.contents;
- branch_names->count = branchlist.length;
- return 0;
-}
-
-typedef struct {
int (*branch_cb)(
const char *branch_name,
git_branch_t branch_type,
diff --git a/tests-clar/refs/branches/listall.c b/tests-clar/refs/branches/listall.c
deleted file mode 100644
index 77f8270..0000000
--- a/tests-clar/refs/branches/listall.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "clar_libgit2.h"
-#include "refs.h"
-#include "branch.h"
-
-static git_repository *repo;
-static git_strarray branch_list;
-static git_reference *fake_remote;
-
-void test_refs_branches_listall__initialize(void)
-{
- git_oid id;
-
- cl_fixture_sandbox("testrepo.git");
- cl_git_pass(git_repository_open(&repo, "testrepo.git"));
-
- cl_git_pass(git_oid_fromstr(&id, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644"));
- cl_git_pass(git_reference_create_oid(&fake_remote, repo, "refs/remotes/nulltoken/master", &id, 0));
-}
-
-void test_refs_branches_listall__cleanup(void)
-{
- git_strarray_free(&branch_list);
- git_reference_free(fake_remote);
- git_repository_free(repo);
-
- cl_fixture_cleanup("testrepo.git");
-}
-
-static void assert_retrieval(unsigned int flags, unsigned int expected_count)
-{
- cl_git_pass(git_branch_list(&branch_list, repo, flags));
-
- cl_assert_equal_i(branch_list.count, expected_count);
-}
-
-void test_refs_branches_listall__retrieve_all_branches(void)
-{
- assert_retrieval(GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE, 9);
-}
-
-void test_refs_branches_listall__retrieve_remote_branches(void)
-{
- assert_retrieval(GIT_BRANCH_REMOTE, 2);
-}
-
-void test_refs_branches_listall__retrieve_local_branches(void)
-{
- assert_retrieval(GIT_BRANCH_LOCAL, 7);
-}
-
-static void assert_branch_list_contains(git_strarray *branches, const char* expected_branch_name)
-{
- unsigned int i;
-
- for (i = 0; i < branches->count; i++) {
- if (strcmp(expected_branch_name, branches->strings[i]) == 0)
- return;
- }
-
- cl_fail("expected branch not found in list.");
-}
-
-/*
- * $ git branch -r
- * nulltoken/HEAD -> nulltoken/master
- * nulltoken/master
- */
-void test_refs_branches_listall__retrieve_remote_symbolic_HEAD_when_present(void)
-{
- git_reference_free(fake_remote);
- cl_git_pass(git_reference_create_symbolic(&fake_remote, repo, "refs/remotes/nulltoken/HEAD", "refs/remotes/nulltoken/master", 0));
-
- cl_git_pass(git_branch_list(&branch_list, repo, GIT_BRANCH_REMOTE));
-
- cl_assert_equal_i(3, branch_list.count);
- assert_branch_list_contains(&branch_list, "remotes/nulltoken/HEAD");
- assert_branch_list_contains(&branch_list, "remotes/nulltoken/master");
-}