refs: Fix error clearing
diff --git a/src/refs.c b/src/refs.c
index 76c9f42..61a515c 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1962,8 +1962,12 @@ int git_reference__is_valid_name(
const char *refname,
unsigned int flags)
{
+ int error;
+
+ error = git_reference__normalize_name(NULL, refname, flags) == 0;
giterr_clear();
- return git_reference__normalize_name(NULL, refname, flags) == 0;
+
+ return error;
}
int git_reference_is_valid_name(