Commit 68a146c1 by Carlos Martín Nieto

refs: don't loose info on resolve error

Typical use is git_reference_resolve(&ref, ref). Currently, if there is
an error, ref will point to NULL, causing the user to lose that
reference.

Always update resolved_ref instead of just on finding an OID ref,
storing the last valid reference in it.

This change helps simplify the code for allowing root commits.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent 7c37aa3a
...@@ -1480,8 +1480,9 @@ int git_reference_resolve(git_reference **resolved_ref, git_reference *ref) ...@@ -1480,8 +1480,9 @@ int git_reference_resolve(git_reference **resolved_ref, git_reference *ref)
for (i = 0; i < MAX_NESTING_LEVEL; ++i) { for (i = 0; i < MAX_NESTING_LEVEL; ++i) {
reference_symbolic *ref_sym; reference_symbolic *ref_sym;
if (ref->type & GIT_REF_OID) {
*resolved_ref = ref; *resolved_ref = ref;
if (ref->type & GIT_REF_OID) {
return GIT_SUCCESS; return GIT_SUCCESS;
} }
......
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