From c128149315c67d52c4503e294bfbd2653e0a8307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Sun, 30 Sep 2012 11:37:53 +0200 Subject: refs: propagate EEXISTS Indicate whether the error comes from the ref already existing or elsewhere. We always perform the check and this lets the user write more concise code. --- src/refs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/refs.c b/src/refs.c index 693870a0b..903acccbb 100644 --- a/src/refs.c +++ b/src/refs.c @@ -1199,6 +1199,7 @@ int git_reference_create_symbolic( { char normalized[GIT_REFNAME_MAX]; git_reference *ref = NULL; + int error; if (git_reference__normalize_name_lax( normalized, @@ -1206,8 +1207,8 @@ int git_reference_create_symbolic( name) < 0) return -1; - if (reference_can_write(repo, normalized, NULL, force) < 0) - return -1; + if ((error = reference_can_write(repo, normalized, NULL, force)) < 0) + return error; if (reference_alloc(&ref, repo, normalized) < 0) return -1; @@ -1236,6 +1237,7 @@ int git_reference_create_oid( const git_oid *id, int force) { + int error; git_reference *ref = NULL; char normalized[GIT_REFNAME_MAX]; @@ -1245,8 +1247,8 @@ int git_reference_create_oid( name) < 0) return -1; - if (reference_can_write(repo, normalized, NULL, force) < 0) - return -1; + if ((error = reference_can_write(repo, normalized, NULL, force)) < 0) + return error; if (reference_alloc(&ref, repo, name) < 0) return -1; -- cgit v1.2.1