Commit 7edb9071 by Jeff King

refdb_fs: do not require peeled packed refs to be tags

Older versions of git would only write peeled entries for
items under refs/tags/. Newer versions will write them for
all refs, and we should be prepared to handle that.
parent d966310c
......@@ -132,10 +132,6 @@ static int packed_parse_peel(
if (tag_ref == NULL)
goto corrupt;
/* Ensure reference is a tag */
if (git__prefixcmp(tag_ref->name, GIT_REFS_TAGS_DIR) != 0)
goto corrupt;
if (buffer + GIT_OID_HEXSZ > buffer_end)
goto corrupt;
......
#include "clar_libgit2.h"
static git_repository *g_repo;
static git_repository *g_peel_repo;
void test_refs_peel__initialize(void)
{
cl_git_pass(git_repository_open(&g_repo, cl_fixture("testrepo.git")));
cl_git_pass(git_repository_open(&g_peel_repo, cl_fixture("peeled.git")));
}
void test_refs_peel__cleanup(void)
{
git_repository_free(g_repo);
g_repo = NULL;
git_repository_free(g_peel_repo);
g_peel_repo = NULL;
}
static void assert_peel(
static void assert_peel_generic(
git_repository *repo,
const char *ref_name,
git_otype requested_type,
const char* expected_sha,
......@@ -23,7 +28,7 @@ static void assert_peel(
git_reference *ref;
git_object *peeled;
cl_git_pass(git_reference_lookup(&ref, g_repo, ref_name));
cl_git_pass(git_reference_lookup(&ref, repo, ref_name));
cl_git_pass(git_reference_peel(&peeled, ref, requested_type));
......@@ -36,6 +41,16 @@ static void assert_peel(
git_reference_free(ref);
}
static void assert_peel(
const char *ref_name,
git_otype requested_type,
const char* expected_sha,
git_otype expected_type)
{
assert_peel_generic(g_repo, ref_name, requested_type,
expected_sha, expected_type);
}
static void assert_peel_error(int error, const char *ref_name, git_otype requested_type)
{
git_reference *ref;
......@@ -90,3 +105,15 @@ void test_refs_peel__can_peel_into_any_non_tag_object(void)
assert_peel("refs/tags/test", GIT_OBJ_ANY,
"e90810b8df3e80c413d903f631643c716887138d", GIT_OBJ_COMMIT);
}
void test_refs_peel__can_peel_fully_peeled_packed_refs(void)
{
assert_peel_generic(g_peel_repo,
"refs/tags/tag-inside-tags", GIT_OBJ_ANY,
"0df1a5865c8abfc09f1f2182e6a31be550e99f07",
GIT_OBJ_COMMIT);
assert_peel_generic(g_peel_repo,
"refs/foo/tag-outside-tags", GIT_OBJ_ANY,
"0df1a5865c8abfc09f1f2182e6a31be550e99f07",
GIT_OBJ_COMMIT);
}
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
url = /home/peff/compile/libgit2/tests-clar/resources/peeled
fetch = +refs/*:refs/*
mirror = true
P pack-e84773eaf3fce1774755580e3dbb8d9f3a1adc45.pack
# pack-refs with: peeled fully-peeled
c2596aa0151888587ec5c0187f261e63412d9e11 refs/foo/tag-outside-tags
^0df1a5865c8abfc09f1f2182e6a31be550e99f07
0df1a5865c8abfc09f1f2182e6a31be550e99f07 refs/heads/master
c2596aa0151888587ec5c0187f261e63412d9e11 refs/tags/tag-inside-tags
^0df1a5865c8abfc09f1f2182e6a31be550e99f07
0df1a5865c8abfc09f1f2182e6a31be550e99f07
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment