summaryrefslogtreecommitdiff
path: root/tests/refs
diff options
context:
space:
mode:
authorEtienne Samson <samson.etienne@gmail.com>2019-07-31 08:37:10 +0200
committerEtienne Samson <samson.etienne@gmail.com>2019-08-21 12:22:03 +0200
commit39d18fe676382cf29ea08427b8ad4527ef51a4bb (patch)
tree55bf3ad2b561b1f5ee9370142b2cf89b5e5b6b82 /tests/refs
parent0f40e68e2f468169d711a806f6839781ae4f7a3e (diff)
downloadlibgit2-39d18fe676382cf29ea08427b8ad4527ef51a4bb.tar.gz
smart: use push_glob instead of manual filtering
The code worked under the assumption that anything under `refs/tags` are tag objects, and all the rest would be peelable to a commit. As it is completely valid to have tags to blobs under a non `refs/tags` ref, this would cause failures when trying to peel a tag to a commit. Fix the broken filtering by switching to `git_revwalk_push_glob`, which already handles this case.
Diffstat (limited to 'tests/refs')
-rw-r--r--tests/refs/foreachglob.c4
-rw-r--r--tests/refs/iterator.c6
2 files changed, 6 insertions, 4 deletions
diff --git a/tests/refs/foreachglob.c b/tests/refs/foreachglob.c
index a13529376..3ff18a27a 100644
--- a/tests/refs/foreachglob.c
+++ b/tests/refs/foreachglob.c
@@ -48,8 +48,8 @@ static void assert_retrieval(const char *glob, int expected_count)
void test_refs_foreachglob__retrieve_all_refs(void)
{
- /* 12 heads (including one packed head) + 1 note + 2 remotes + 7 tags */
- assert_retrieval("*", 22);
+ /* 12 heads (including one packed head) + 1 note + 2 remotes + 7 tags + 1 blob */
+ assert_retrieval("*", 23);
}
void test_refs_foreachglob__retrieve_remote_branches(void)
diff --git a/tests/refs/iterator.c b/tests/refs/iterator.c
index 18e9d1d5b..8d52755c2 100644
--- a/tests/refs/iterator.c
+++ b/tests/refs/iterator.c
@@ -15,6 +15,7 @@ void test_refs_iterator__cleanup(void)
}
static const char *refnames[] = {
+ "refs/blobs/annotated_tag_to_blob",
"refs/heads/br2",
"refs/heads/cannot-fetch",
"refs/heads/chomped",
@@ -40,6 +41,7 @@ static const char *refnames[] = {
};
static const char *refnames_with_symlink[] = {
+ "refs/blobs/annotated_tag_to_blob",
"refs/heads/br2",
"refs/heads/cannot-fetch",
"refs/heads/chomped",
@@ -99,7 +101,7 @@ void test_refs_iterator__list(void)
git_vector output;
git_reference *ref;
- cl_git_pass(git_vector_init(&output, 32, &refcmp_cb));
+ cl_git_pass(git_vector_init(&output, 33, &refcmp_cb));
cl_git_pass(git_reference_iterator_new(&iter, repo));
while (1) {
@@ -143,7 +145,7 @@ static int refs_foreach_cb(git_reference *reference, void *payload)
void test_refs_iterator__foreach(void)
{
git_vector output;
- cl_git_pass(git_vector_init(&output, 32, &refcmp_cb));
+ cl_git_pass(git_vector_init(&output, 33, &refcmp_cb));
cl_git_pass(git_reference_foreach(repo, refs_foreach_cb, &output));
assert_all_refnames_match(refnames, &output);
}