mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-13 21:26:20 +00:00
refs: Reword errors
This commit is contained in:
parent
5bdf7b9f54
commit
0d5d5190f2
21
src/refs.c
21
src/refs.c
@ -1489,16 +1489,15 @@ int git_reference_resolve(git_reference **resolved_ref, git_reference *ref)
|
|||||||
|
|
||||||
*resolved_ref = ref;
|
*resolved_ref = ref;
|
||||||
|
|
||||||
if (ref->type & GIT_REF_OID) {
|
if (ref->type & GIT_REF_OID)
|
||||||
return GIT_SUCCESS;
|
return GIT_SUCCESS;
|
||||||
}
|
|
||||||
|
|
||||||
ref_sym = (reference_symbolic *)ref;
|
ref_sym = (reference_symbolic *)ref;
|
||||||
if ((error = git_reference_lookup(&ref, repo, ref_sym->target)) < GIT_SUCCESS)
|
if ((error = git_reference_lookup(&ref, repo, ref_sym->target)) < GIT_SUCCESS)
|
||||||
return git__rethrow(error, "Failed to resolve reference");
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return git__throw(GIT_ETOONESTEDSYMREF, "Failed to resolve reference. Reference is too nested");
|
return git__throw(GIT_ENOMEM, "Failed to resolve reference. Reference is too nested");
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_reference_packall(git_repository *repo)
|
int git_reference_packall(git_repository *repo)
|
||||||
@ -1533,7 +1532,7 @@ int git_reference_listcb(git_repository *repo, unsigned int list_flags, int (*ca
|
|||||||
|
|
||||||
GIT_HASHTABLE_FOREACH(repo->references.packfile, ref_name, _unused,
|
GIT_HASHTABLE_FOREACH(repo->references.packfile, ref_name, _unused,
|
||||||
if ((error = callback(ref_name, payload)) < GIT_SUCCESS)
|
if ((error = callback(ref_name, payload)) < GIT_SUCCESS)
|
||||||
return git__rethrow(error, "Failed to list references");
|
return git__throw(error, "Failed to list references. User callback failed");
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1573,7 +1572,7 @@ int git_reference_listall(git_strarray *array, git_repository *repo, unsigned in
|
|||||||
|
|
||||||
if (error < GIT_SUCCESS) {
|
if (error < GIT_SUCCESS) {
|
||||||
git_vector_free(&ref_list);
|
git_vector_free(&ref_list);
|
||||||
return git__rethrow(error, "Failed to list references");
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
array->strings = (char **)ref_list.contents;
|
array->strings = (char **)ref_list.contents;
|
||||||
@ -1632,7 +1631,7 @@ void git_repository__refcache_free(git_refcache *refs)
|
|||||||
static int check_valid_ref_char(char ch)
|
static int check_valid_ref_char(char ch)
|
||||||
{
|
{
|
||||||
if (ch <= ' ')
|
if (ch <= ' ')
|
||||||
return git__throw(GIT_ERROR, "Not a valid reference char");
|
return GIT_ERROR;
|
||||||
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '~':
|
case '~':
|
||||||
@ -1642,7 +1641,7 @@ static int check_valid_ref_char(char ch)
|
|||||||
case '?':
|
case '?':
|
||||||
case '[':
|
case '[':
|
||||||
case '*':
|
case '*':
|
||||||
return git__throw(GIT_ERROR, "Not a valid reference char");
|
return GIT_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1652,7 +1651,6 @@ static int check_valid_ref_char(char ch)
|
|||||||
|
|
||||||
static int normalize_name(char *buffer_out, const char *name, int is_oid_ref)
|
static int normalize_name(char *buffer_out, const char *name, int is_oid_ref)
|
||||||
{
|
{
|
||||||
int error = GIT_SUCCESS;
|
|
||||||
const char *name_end, *buffer_out_start;
|
const char *name_end, *buffer_out_start;
|
||||||
char *current;
|
char *current;
|
||||||
int contains_a_slash = 0;
|
int contains_a_slash = 0;
|
||||||
@ -1715,12 +1713,11 @@ static int normalize_name(char *buffer_out, const char *name, int is_oid_ref)
|
|||||||
* For object id references, name has to start with refs/. Again,
|
* For object id references, name has to start with refs/. Again,
|
||||||
* we need to allow HEAD to be in a detached state.
|
* we need to allow HEAD to be in a detached state.
|
||||||
*/
|
*/
|
||||||
if (is_oid_ref &&
|
if (is_oid_ref && !(git__prefixcmp(buffer_out_start, GIT_REFS_DIR) ||
|
||||||
!(git__prefixcmp(buffer_out_start, GIT_REFS_DIR) ||
|
|
||||||
strcmp(buffer_out_start, GIT_HEAD_FILE)))
|
strcmp(buffer_out_start, GIT_HEAD_FILE)))
|
||||||
return git__throw(GIT_EINVALIDREFNAME, "Failed to normalize name. Reference name does not start with 'refs/'");
|
return git__throw(GIT_EINVALIDREFNAME, "Failed to normalize name. Reference name does not start with 'refs/'");
|
||||||
|
|
||||||
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to normalize name");
|
return GIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_reference__normalize_name(char *buffer_out, const char *name)
|
int git_reference__normalize_name(char *buffer_out, const char *name)
|
||||||
|
Loading…
Reference in New Issue
Block a user