Commit cb35094b by Scott J. Goldman

Allow peeled references without trailing newline at end of file

Also ammends one of the tag tests to make sure it's working.
parent 2a707d0e
......@@ -328,7 +328,7 @@ static int packed_parse_peel(
if (git__prefixcmp(tag_ref->name, GIT_REFS_TAGS_DIR) != 0)
goto corrupt;
if (buffer + GIT_OID_HEXSZ >= buffer_end)
if (buffer + GIT_OID_HEXSZ > buffer_end)
goto corrupt;
/* Is this a valid object id? */
......@@ -339,10 +339,14 @@ static int packed_parse_peel(
if (*buffer == '\r')
buffer++;
if (*buffer != '\n')
goto corrupt;
if (buffer != buffer_end) {
if (*buffer == '\n')
buffer++;
else
goto corrupt;
}
*buffer_out = buffer + 1;
*buffer_out = buffer;
return 0;
corrupt:
......
......@@ -62,6 +62,7 @@ void test_object_tag_read__parse_without_tagger(void)
git_tag *bad_tag;
git_commit *commit;
git_oid id, id_commit;
git_strarray ref_list;
// TODO: This is a little messy
cl_git_pass(git_repository_open(&bad_tag_repo, cl_fixture("bad_tag.git")));
......@@ -81,6 +82,9 @@ void test_object_tag_read__parse_without_tagger(void)
cl_assert(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0);
cl_git_pass(git_reference_list(&ref_list, bad_tag_repo, GIT_REF_LISTALL));
git_strarray_free(&ref_list);
git_tag_free(bad_tag);
git_commit_free(commit);
git_repository_free(bad_tag_repo);
......
# pack-refs with: peeled
eda9f45a2a98d4c17a09d681d88569fa4ea91755 refs/tags/e90810b
^e90810b8df3e80c413d903f631643c716887138d
d3bacb8d3ff25876a961b1963b6515170d0151ab refs/tags/hello
^6dcf9bf7541ee10456529833502442f385010c3d
\ No newline at end of file
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