Commit 7ae5ab56 by Carlos Martín Nieto

Fix leak in the tests

Also introduce the slective ref trimming promised but also missed in
the previous commit.
parent 47f44b6e
...@@ -211,8 +211,6 @@ static int loose_lookup(git_reference *ref) ...@@ -211,8 +211,6 @@ static int loose_lookup(git_reference *ref)
if (!updated) if (!updated)
return 0; return 0;
git_buf_rtrim(&ref_file);
if (ref->flags & GIT_REF_SYMBOLIC) { if (ref->flags & GIT_REF_SYMBOLIC) {
git__free(ref->target.symbolic); git__free(ref->target.symbolic);
ref->target.symbolic = NULL; ref->target.symbolic = NULL;
...@@ -222,6 +220,7 @@ static int loose_lookup(git_reference *ref) ...@@ -222,6 +220,7 @@ static int loose_lookup(git_reference *ref)
if (git__prefixcmp((const char *)(ref_file.ptr), GIT_SYMREF) == 0) { if (git__prefixcmp((const char *)(ref_file.ptr), GIT_SYMREF) == 0) {
ref->flags |= GIT_REF_SYMBOLIC; ref->flags |= GIT_REF_SYMBOLIC;
git_buf_rtrim(&ref_file);
result = loose_parse_symbolic(ref, &ref_file); result = loose_parse_symbolic(ref, &ref_file);
} else { } else {
ref->flags |= GIT_REF_OID; ref->flags |= GIT_REF_OID;
......
...@@ -212,6 +212,7 @@ void test_refs_read__trailing(void) ...@@ -212,6 +212,7 @@ void test_refs_read__trailing(void)
cl_git_pass(git_reference_lookup(&test, g_repo, "refs/heads/test")); cl_git_pass(git_reference_lookup(&test, g_repo, "refs/heads/test"));
cl_git_pass(git_reference_lookup(&trailing, g_repo, "refs/heads/trailing")); cl_git_pass(git_reference_lookup(&trailing, g_repo, "refs/heads/trailing"));
cl_git_pass(git_oid_cmp(git_reference_oid(test), git_reference_oid(trailing))); cl_git_pass(git_oid_cmp(git_reference_oid(test), git_reference_oid(trailing)));
git_reference_free(trailing);
cl_git_pass(git_reference_lookup(&trailing, g_repo, "FETCH_HEAD")); cl_git_pass(git_reference_lookup(&trailing, g_repo, "FETCH_HEAD"));
git_reference_free(test); git_reference_free(test);
......
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