improve error codes in lib/reference.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/lib/reference.c b/lib/reference.c
index 8cf17a7..1d64acc 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -75,7 +75,7 @@ parse_symref(struct got_reference **ref, const char *name, const char *line)
char *symref_ref;
if (line[0] == '\0')
- return got_error(GOT_ERR_NOT_REF);
+ return got_error(GOT_ERR_BAD_REF_DATA);
symref_name = strdup(name);
if (symref_name == NULL)
@@ -113,7 +113,7 @@ parse_ref_line(struct got_reference **ref, const char *name, const char *line)
return got_error_from_errno();
if (!got_parse_sha1_digest(digest, line))
- return got_error(GOT_ERR_NOT_REF);
+ return got_error(GOT_ERR_BAD_REF_DATA);
*ref = calloc(1, sizeof(**ref));
if (*ref == NULL)
@@ -134,11 +134,11 @@ parse_ref_file(struct got_reference **ref, const char *name,
const char delim[3] = {'\0', '\0', '\0'};
if (f == NULL)
- return got_error(GOT_ERR_NOT_REF);
+ return got_error_not_ref(name);
line = fparseln(f, &len, NULL, delim, 0);
if (line == NULL) {
- err = got_error(GOT_ERR_NOT_REF);
+ err = got_error(GOT_ERR_BAD_REF_DATA);
goto done;
}
@@ -180,7 +180,7 @@ parse_packed_ref_line(struct got_reference **ref, const char *abs_refname,
return NULL;
if (!got_parse_sha1_digest(digest, line))
- return got_error(GOT_ERR_NOT_REF);
+ return got_error(GOT_ERR_BAD_REF_DATA);
if (abs_refname) {
if (strcmp(line + SHA1_DIGEST_STRING_LENGTH, abs_refname) != 0)
@@ -216,7 +216,7 @@ open_packed_ref(struct got_reference **ref, FILE *f, const char **subdirs,
do {
line = fparseln(f, &len, NULL, delim, 0);
if (line == NULL) {
- err = got_error(GOT_ERR_NOT_REF);
+ err = got_error_not_ref(refname);
break;
}
for (i = 0; i < nsubdirs; i++) {
@@ -251,7 +251,7 @@ open_ref(struct got_reference **ref, const char *path_refs, const char *subdir,
normpath = got_path_normalize(path_ref);
if (normpath == NULL) {
- err = got_error(GOT_ERR_NOT_REF);
+ err = got_error_from_errno();
goto done;
}