Commit 53774eb8185e08da46cd322dc8fefaff7676fea4

Vicent Martí 2012-06-13T08:59:32

Merge pull request #764 from sleeper/issue_763 Fix issue #763

diff --git a/src/branch.c b/src/branch.c
index 5d5a240..8b97a82 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -149,9 +149,11 @@ 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)
-		|| (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));
+	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;
 }
diff --git a/tests-clar/refs/branches/listall.c b/tests-clar/refs/branches/listall.c
index 49e1924..77f8270 100644
--- a/tests-clar/refs/branches/listall.c
+++ b/tests-clar/refs/branches/listall.c
@@ -73,6 +73,6 @@ void test_refs_branches_listall__retrieve_remote_symbolic_HEAD_when_present(void
 	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, "refs/remotes/nulltoken/HEAD");
-	assert_branch_list_contains(&branch_list, "refs/remotes/nulltoken/master");
+	assert_branch_list_contains(&branch_list, "remotes/nulltoken/HEAD");
+	assert_branch_list_contains(&branch_list, "remotes/nulltoken/master");
 }