commit 30c0868d39a478a260b1a028088d633785bf6da1 from: Stefan Sperling date: Sun Feb 03 16:08:03 2019 UTC improve error codes in lib/reference.c commit - a808cfa5a739af830d2426a0fa3b420425d0037b commit + 30c0868d39a478a260b1a028088d633785bf6da1 blob - 8cf17a7dc99101cfd244574281974a3b86e0d666 blob + 1d64acc3e5b59aa53a4c744828a2b66f11618e57 --- lib/reference.c +++ lib/reference.c @@ -75,7 +75,7 @@ parse_symref(struct got_reference **ref, const char *n 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 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 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, cons 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, c 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_ normpath = got_path_normalize(path_ref); if (normpath == NULL) { - err = got_error(GOT_ERR_NOT_REF); + err = got_error_from_errno(); goto done; }