Commit 03c28d92 by Vicent Martí

Merge pull request #1526 from arrbee/cleanup-error-return-without-msg

Make sure error messages are set for most error returns
parents d5e5bbd7 6e286e8d
...@@ -185,7 +185,7 @@ int git_branch_move( ...@@ -185,7 +185,7 @@ int git_branch_move(
git_buf_cstr(&old_config_section), git_buf_cstr(&old_config_section),
git_buf_cstr(&new_config_section))) < 0) git_buf_cstr(&new_config_section))) < 0)
goto done; goto done;
if ((error = git_reference_rename(out, branch, git_buf_cstr(&new_reference_name), force)) < 0) if ((error = git_reference_rename(out, branch, git_buf_cstr(&new_reference_name), force)) < 0)
goto done; goto done;
...@@ -276,6 +276,8 @@ int git_branch_upstream__name( ...@@ -276,6 +276,8 @@ int git_branch_upstream__name(
goto cleanup; goto cleanup;
if (!*remote_name || !*merge_name) { if (!*remote_name || !*merge_name) {
giterr_set(GITERR_REFERENCE,
"branch '%s' does not have an upstream", canonical_branch_name);
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
goto cleanup; goto cleanup;
} }
...@@ -342,6 +344,9 @@ static int remote_name(git_buf *buf, git_repository *repo, const char *canonical ...@@ -342,6 +344,9 @@ static int remote_name(git_buf *buf, git_repository *repo, const char *canonical
remote_name = remote_list.strings[i]; remote_name = remote_list.strings[i];
} else { } else {
git_remote_free(remote); git_remote_free(remote);
giterr_set(GITERR_REFERENCE,
"Reference '%s' is ambiguous", canonical_branch_name);
error = GIT_EAMBIGUOUS; error = GIT_EAMBIGUOUS;
goto cleanup; goto cleanup;
} }
...@@ -354,6 +359,8 @@ static int remote_name(git_buf *buf, git_repository *repo, const char *canonical ...@@ -354,6 +359,8 @@ static int remote_name(git_buf *buf, git_repository *repo, const char *canonical
git_buf_clear(buf); git_buf_clear(buf);
error = git_buf_puts(buf, remote_name); error = git_buf_puts(buf, remote_name);
} else { } else {
giterr_set(GITERR_REFERENCE,
"Could not determine remote for '%s'", canonical_branch_name);
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
} }
...@@ -490,8 +497,11 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name) ...@@ -490,8 +497,11 @@ int git_branch_set_upstream(git_reference *branch, const char *upstream_name)
local = 1; local = 1;
else if (git_branch_lookup(&upstream, repo, upstream_name, GIT_BRANCH_REMOTE) == 0) else if (git_branch_lookup(&upstream, repo, upstream_name, GIT_BRANCH_REMOTE) == 0)
local = 0; local = 0;
else else {
giterr_set(GITERR_REFERENCE,
"Cannot set upstream for branch '%s'", shortname);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
}
/* /*
* If it's local, the remote is "." and the branch name is * If it's local, the remote is "." and the branch name is
......
...@@ -397,18 +397,6 @@ on_error: ...@@ -397,18 +397,6 @@ on_error:
} }
static bool path_is_okay(const char *path)
{
/* The path must either not exist, or be an empty directory */
if (!git_path_exists(path)) return true;
if (!git_path_is_empty_dir(path)) {
giterr_set(GITERR_INVALID,
"'%s' exists and is not an empty directory", path);
return false;
}
return true;
}
static bool should_checkout( static bool should_checkout(
git_repository *repo, git_repository *repo,
bool is_bare, bool is_bare,
...@@ -454,7 +442,10 @@ int git_clone( ...@@ -454,7 +442,10 @@ int git_clone(
normalize_options(&normOptions, options); normalize_options(&normOptions, options);
GITERR_CHECK_VERSION(&normOptions, GIT_CLONE_OPTIONS_VERSION, "git_clone_options"); GITERR_CHECK_VERSION(&normOptions, GIT_CLONE_OPTIONS_VERSION, "git_clone_options");
if (!path_is_okay(local_path)) { /* Only clone to a new directory or an empty directory */
if (git_path_exists(local_path) && !git_path_is_empty_dir(local_path)) {
giterr_set(GITERR_INVALID,
"'%s' exists and is not an empty directory", local_path);
return GIT_ERROR; return GIT_ERROR;
} }
......
...@@ -344,6 +344,13 @@ int git_config_delete_entry(git_config *cfg, const char *name) ...@@ -344,6 +344,13 @@ int git_config_delete_entry(git_config *cfg, const char *name)
* Setters * Setters
**************/ **************/
static int config_error_nofiles(const char *name)
{
giterr_set(GITERR_CONFIG,
"Cannot set value for '%s' when no config files exist", name);
return GIT_ENOTFOUND;
}
int git_config_set_int64(git_config *cfg, const char *name, int64_t value) int git_config_set_int64(git_config *cfg, const char *name, int64_t value)
{ {
char str_value[32]; /* All numbers should fit in here */ char str_value[32]; /* All numbers should fit in here */
...@@ -373,12 +380,9 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value) ...@@ -373,12 +380,9 @@ int git_config_set_string(git_config *cfg, const char *name, const char *value)
} }
internal = git_vector_get(&cfg->files, 0); internal = git_vector_get(&cfg->files, 0);
if (!internal) { if (!internal)
/* Should we auto-vivify .git/config? Tricky from this location */ /* Should we auto-vivify .git/config? Tricky from this location */
giterr_set(GITERR_CONFIG, "Cannot set value when no config files exist"); return config_error_nofiles(name);
return GIT_ENOTFOUND;
}
file = internal->file; file = internal->file;
error = file->set(file, name, value); error = file->set(file, name, value);
...@@ -442,6 +446,12 @@ static int get_string_at_file(const char **out, const git_config_backend *file, ...@@ -442,6 +446,12 @@ static int get_string_at_file(const char **out, const git_config_backend *file,
return res; return res;
} }
static int config_error_notfound(const char *name)
{
giterr_set(GITERR_CONFIG, "Config value '%s' was not found", name);
return GIT_ENOTFOUND;
}
static int get_string(const char **out, const git_config *cfg, const char *name) static int get_string(const char **out, const git_config *cfg, const char *name)
{ {
file_internal *internal; file_internal *internal;
...@@ -454,7 +464,7 @@ static int get_string(const char **out, const git_config *cfg, const char *name) ...@@ -454,7 +464,7 @@ static int get_string(const char **out, const git_config *cfg, const char *name)
return res; return res;
} }
return GIT_ENOTFOUND; return config_error_notfound(name);
} }
int git_config_get_bool(int *out, const git_config *cfg, const char *name) int git_config_get_bool(int *out, const git_config *cfg, const char *name)
...@@ -494,7 +504,7 @@ int git_config_get_entry(const git_config_entry **out, const git_config *cfg, co ...@@ -494,7 +504,7 @@ int git_config_get_entry(const git_config_entry **out, const git_config *cfg, co
return ret; return ret;
} }
return GIT_ENOTFOUND; return config_error_notfound(name);
} }
int git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp, int git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp,
...@@ -517,7 +527,7 @@ int git_config_get_multivar(const git_config *cfg, const char *name, const char ...@@ -517,7 +527,7 @@ int git_config_get_multivar(const git_config *cfg, const char *name, const char
return ret; return ret;
} }
return 0; return (ret == GIT_ENOTFOUND) ? config_error_notfound(name) : 0;
} }
int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value) int git_config_set_multivar(git_config *cfg, const char *name, const char *regexp, const char *value)
...@@ -526,6 +536,8 @@ int git_config_set_multivar(git_config *cfg, const char *name, const char *regex ...@@ -526,6 +536,8 @@ int git_config_set_multivar(git_config *cfg, const char *name, const char *regex
file_internal *internal; file_internal *internal;
internal = git_vector_get(&cfg->files, 0); internal = git_vector_get(&cfg->files, 0);
if (!internal)
return config_error_nofiles(name);
file = internal->file; file = internal->file;
return file->set_multivar(file, name, regexp, value); return file->set_multivar(file, name, regexp, value);
......
...@@ -1611,6 +1611,12 @@ int git_diff_patch_line_stats( ...@@ -1611,6 +1611,12 @@ int git_diff_patch_line_stats(
return 0; return 0;
} }
static int diff_error_outofrange(const char *thing)
{
giterr_set(GITERR_INVALID, "Diff patch %s index out of range", thing);
return GIT_ENOTFOUND;
}
int git_diff_patch_get_hunk( int git_diff_patch_get_hunk(
const git_diff_range **range, const git_diff_range **range,
const char **header, const char **header,
...@@ -1628,7 +1634,8 @@ int git_diff_patch_get_hunk( ...@@ -1628,7 +1634,8 @@ int git_diff_patch_get_hunk(
if (header) *header = NULL; if (header) *header = NULL;
if (header_len) *header_len = 0; if (header_len) *header_len = 0;
if (lines_in_hunk) *lines_in_hunk = 0; if (lines_in_hunk) *lines_in_hunk = 0;
return GIT_ENOTFOUND;
return diff_error_outofrange("hunk");
} }
hunk = &patch->hunks[hunk_idx]; hunk = &patch->hunks[hunk_idx];
...@@ -1648,7 +1655,7 @@ int git_diff_patch_num_lines_in_hunk( ...@@ -1648,7 +1655,7 @@ int git_diff_patch_num_lines_in_hunk(
assert(patch); assert(patch);
if (hunk_idx >= patch->hunks_size) if (hunk_idx >= patch->hunks_size)
return GIT_ENOTFOUND; return diff_error_outofrange("hunk");
else else
return (int)patch->hunks[hunk_idx].line_count; return (int)patch->hunks[hunk_idx].line_count;
} }
...@@ -1665,15 +1672,20 @@ int git_diff_patch_get_line_in_hunk( ...@@ -1665,15 +1672,20 @@ int git_diff_patch_get_line_in_hunk(
{ {
diff_patch_hunk *hunk; diff_patch_hunk *hunk;
diff_patch_line *line; diff_patch_line *line;
const char *thing;
assert(patch); assert(patch);
if (hunk_idx >= patch->hunks_size) if (hunk_idx >= patch->hunks_size) {
thing = "hunk";
goto notfound; goto notfound;
}
hunk = &patch->hunks[hunk_idx]; hunk = &patch->hunks[hunk_idx];
if (line_of_hunk >= hunk->line_count) if (line_of_hunk >= hunk->line_count) {
thing = "link";
goto notfound; goto notfound;
}
line = &patch->lines[hunk->line_start + line_of_hunk]; line = &patch->lines[hunk->line_start + line_of_hunk];
...@@ -1692,7 +1704,7 @@ notfound: ...@@ -1692,7 +1704,7 @@ notfound:
if (old_lineno) *old_lineno = -1; if (old_lineno) *old_lineno = -1;
if (new_lineno) *new_lineno = -1; if (new_lineno) *new_lineno = -1;
return GIT_ENOTFOUND; return diff_error_outofrange(thing);
} }
static int print_to_buffer_cb( static int print_to_buffer_cb(
......
...@@ -988,8 +988,10 @@ int git_futils_filestamp_check( ...@@ -988,8 +988,10 @@ int git_futils_filestamp_check(
if (stamp == NULL) if (stamp == NULL)
return 1; return 1;
if (p_stat(path, &st) < 0) if (p_stat(path, &st) < 0) {
giterr_set(GITERR_OS, "Could not stat '%s'", path);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
}
if (stamp->mtime == (git_time_t)st.st_mtime && if (stamp->mtime == (git_time_t)st.st_mtime &&
stamp->size == (git_off_t)st.st_size && stamp->size == (git_off_t)st.st_size &&
......
...@@ -547,8 +547,10 @@ const git_index_entry *git_index_get_bypath( ...@@ -547,8 +547,10 @@ const git_index_entry *git_index_get_bypath(
git_vector_sort(&index->entries); git_vector_sort(&index->entries);
if (index_find(&pos, index, path, stage) < 0) if (index_find(&pos, index, path, stage) < 0) {
giterr_set(GITERR_INDEX, "Index does not contain %s", path);
return NULL; return NULL;
}
return git_index_get_byindex(index, pos); return git_index_get_byindex(index, pos);
} }
...@@ -830,8 +832,11 @@ int git_index_remove(git_index *index, const char *path, int stage) ...@@ -830,8 +832,11 @@ int git_index_remove(git_index *index, const char *path, int stage)
git_vector_sort(&index->entries); git_vector_sort(&index->entries);
if (index_find(&position, index, path, stage) < 0) if (index_find(&position, index, path, stage) < 0) {
giterr_set(GITERR_INDEX, "Index does not contain %s at stage %d",
path, stage);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
}
entry = git_vector_get(&index->entries, position); entry = git_vector_get(&index->entries, position);
if (entry != NULL) if (entry != NULL)
......
...@@ -127,6 +127,7 @@ int git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_ ...@@ -127,6 +127,7 @@ int git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_
goto cleanup; goto cleanup;
if (!result) { if (!result) {
giterr_set(GITERR_MERGE, "No merge base found");
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
goto cleanup; goto cleanup;
} }
...@@ -172,7 +173,7 @@ int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const ...@@ -172,7 +173,7 @@ int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const
if (!result) { if (!result) {
git_revwalk_free(walk); git_revwalk_free(walk);
giterr_clear(); giterr_set(GITERR_MERGE, "No merge base found");
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
......
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
#include "iterator.h" #include "iterator.h"
#include "signature.h" #include "signature.h"
static int note_error_notfound(void)
{
giterr_set(GITERR_INVALID, "Note could not be found");
return GIT_ENOTFOUND;
}
static int find_subtree_in_current_level( static int find_subtree_in_current_level(
git_tree **out, git_tree **out,
git_repository *repo, git_repository *repo,
...@@ -26,7 +32,7 @@ static int find_subtree_in_current_level( ...@@ -26,7 +32,7 @@ static int find_subtree_in_current_level(
*out = NULL; *out = NULL;
if (parent == NULL) if (parent == NULL)
return GIT_ENOTFOUND; return note_error_notfound();
for (i = 0; i < git_tree_entrycount(parent); i++) { for (i = 0; i < git_tree_entrycount(parent); i++) {
entry = git_tree_entry_byindex(parent, i); entry = git_tree_entry_byindex(parent, i);
...@@ -44,7 +50,7 @@ static int find_subtree_in_current_level( ...@@ -44,7 +50,7 @@ static int find_subtree_in_current_level(
return GIT_EEXISTS; return GIT_EEXISTS;
} }
return GIT_ENOTFOUND; return note_error_notfound();
} }
static int find_subtree_r(git_tree **out, git_tree *root, static int find_subtree_r(git_tree **out, git_tree *root,
...@@ -56,9 +62,8 @@ static int find_subtree_r(git_tree **out, git_tree *root, ...@@ -56,9 +62,8 @@ static int find_subtree_r(git_tree **out, git_tree *root,
*out = NULL; *out = NULL;
error = find_subtree_in_current_level(&subtree, repo, root, target, *fanout); error = find_subtree_in_current_level(&subtree, repo, root, target, *fanout);
if (error == GIT_EEXISTS) { if (error == GIT_EEXISTS)
return git_tree_lookup(out, repo, git_tree_id(root)); return git_tree_lookup(out, repo, git_tree_id(root));
}
if (error < 0) if (error < 0)
return error; return error;
...@@ -85,7 +90,8 @@ static int find_blob(git_oid *blob, git_tree *tree, const char *target) ...@@ -85,7 +90,8 @@ static int find_blob(git_oid *blob, git_tree *tree, const char *target)
return 0; return 0;
} }
} }
return GIT_ENOTFOUND;
return note_error_notfound();
} }
static int tree_write( static int tree_write(
...@@ -316,8 +322,8 @@ static int note_new(git_note **out, git_oid *note_oid, git_blob *blob) ...@@ -316,8 +322,8 @@ static int note_new(git_note **out, git_oid *note_oid, git_blob *blob)
return 0; return 0;
} }
static int note_lookup(git_note **out, git_repository *repo, static int note_lookup(
git_tree *tree, const char *target) git_note **out, git_repository *repo, git_tree *tree, const char *target)
{ {
int error, fanout = 0; int error, fanout = 0;
git_oid oid; git_oid oid;
...@@ -382,6 +388,7 @@ static int note_get_default_ref(const char **out, git_repository *repo) ...@@ -382,6 +388,7 @@ static int note_get_default_ref(const char **out, git_repository *repo)
ret = git_config_get_string(out, cfg, "core.notesRef"); ret = git_config_get_string(out, cfg, "core.notesRef");
if (ret == GIT_ENOTFOUND) { if (ret == GIT_ENOTFOUND) {
giterr_clear();
*out = GIT_NOTES_DEFAULT_REF; *out = GIT_NOTES_DEFAULT_REF;
return 0; return 0;
} }
...@@ -432,12 +439,10 @@ int git_note_read(git_note **out, git_repository *repo, ...@@ -432,12 +439,10 @@ int git_note_read(git_note **out, git_repository *repo,
target = git_oid_allocfmt(oid); target = git_oid_allocfmt(oid);
GITERR_CHECK_ALLOC(target); GITERR_CHECK_ALLOC(target);
if ((error = retrieve_note_tree_and_commit(&tree, &commit, repo, &notes_ref)) < 0) if (!(error = retrieve_note_tree_and_commit(
goto cleanup; &tree, &commit, repo, &notes_ref)))
error = note_lookup(out, repo, tree, target);
error = note_lookup(out, repo, tree, target);
cleanup:
git__free(target); git__free(target);
git_tree_free(tree); git_tree_free(tree);
git_commit_free(commit); git_commit_free(commit);
...@@ -489,13 +494,11 @@ int git_note_remove(git_repository *repo, const char *notes_ref, ...@@ -489,13 +494,11 @@ int git_note_remove(git_repository *repo, const char *notes_ref,
target = git_oid_allocfmt(oid); target = git_oid_allocfmt(oid);
GITERR_CHECK_ALLOC(target); GITERR_CHECK_ALLOC(target);
if ((error = retrieve_note_tree_and_commit(&tree, &commit, repo, &notes_ref)) < 0) if (!(error = retrieve_note_tree_and_commit(
goto cleanup; &tree, &commit, repo, &notes_ref)))
error = note_remove(
error = note_remove(repo, author, committer, notes_ref, repo, author, committer, notes_ref, tree, target, &commit);
tree, target, &commit);
cleanup:
git__free(target); git__free(target);
git_commit_free(commit); git_commit_free(commit);
git_tree_free(tree); git_tree_free(tree);
...@@ -533,7 +536,7 @@ static int process_entry_path( ...@@ -533,7 +536,7 @@ static int process_entry_path(
const char* entry_path, const char* entry_path,
git_oid *annotated_object_id) git_oid *annotated_object_id)
{ {
int error = -1; int error = 0;
size_t i = 0, j = 0, len; size_t i = 0, j = 0, len;
git_buf buf = GIT_BUF_INIT; git_buf buf = GIT_BUF_INIT;
......
...@@ -122,8 +122,10 @@ int git_object_lookup_prefix( ...@@ -122,8 +122,10 @@ int git_object_lookup_prefix(
assert(repo && object_out && id); assert(repo && object_out && id);
if (len < GIT_OID_MINPREFIXLEN) if (len < GIT_OID_MINPREFIXLEN) {
giterr_set(GITERR_OBJECT, "Ambiguous lookup - OID prefix is too short");
return GIT_EAMBIGUOUS; return GIT_EAMBIGUOUS;
}
error = git_repository_odb__weakptr(&odb, repo); error = git_repository_odb__weakptr(&odb, repo);
if (error < 0) if (error < 0)
...@@ -311,18 +313,17 @@ int git_object_peel( ...@@ -311,18 +313,17 @@ int git_object_peel(
git_object *source, *deref = NULL; git_object *source, *deref = NULL;
int error; int error;
if (target_type != GIT_OBJ_TAG &&
target_type != GIT_OBJ_COMMIT &&
target_type != GIT_OBJ_TREE &&
target_type != GIT_OBJ_BLOB &&
target_type != GIT_OBJ_ANY)
return GIT_EINVALIDSPEC;
assert(object && peeled); assert(object && peeled);
if (git_object_type(object) == target_type) if (git_object_type(object) == target_type)
return git_object_dup(peeled, (git_object *)object); return git_object_dup(peeled, (git_object *)object);
assert(target_type == GIT_OBJ_TAG ||
target_type == GIT_OBJ_COMMIT ||
target_type == GIT_OBJ_TREE ||
target_type == GIT_OBJ_BLOB ||
target_type == GIT_OBJ_ANY);
source = (git_object *)object; source = (git_object *)object;
while (!(error = dereference_object(&deref, source))) { while (!(error = dereference_object(&deref, source))) {
......
...@@ -424,6 +424,14 @@ size_t git_odb_num_backends(git_odb *odb) ...@@ -424,6 +424,14 @@ size_t git_odb_num_backends(git_odb *odb)
return odb->backends.length; return odb->backends.length;
} }
static int git_odb__error_unsupported_in_backend(const char *action)
{
giterr_set(GITERR_ODB,
"Cannot %s - unsupported in the loaded odb backends", action);
return -1;
}
int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos) int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos)
{ {
backend_internal *internal; backend_internal *internal;
...@@ -436,6 +444,7 @@ int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos) ...@@ -436,6 +444,7 @@ int git_odb_get_backend(git_odb_backend **out, git_odb *odb, size_t pos)
return 0; return 0;
} }
giterr_set(GITERR_ODB, "No ODB backend loaded at index " PRIuZ, pos);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
...@@ -472,7 +481,7 @@ static int add_default_backends( ...@@ -472,7 +481,7 @@ static int add_default_backends(
return 0; return 0;
} }
#endif #endif
/* add the loose object backend */ /* add the loose object backend */
if (git_odb_backend_loose(&loose, objects_dir, -1, 0) < 0 || if (git_odb_backend_loose(&loose, objects_dir, -1, 0) < 0 ||
add_backend_internal(db, loose, GIT_LOOSE_PRIORITY, as_alternates, inode) < 0) add_backend_internal(db, loose, GIT_LOOSE_PRIORITY, as_alternates, inode) < 0)
...@@ -495,9 +504,8 @@ static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_ ...@@ -495,9 +504,8 @@ static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_
int result = 0; int result = 0;
/* Git reports an error, we just ignore anything deeper */ /* Git reports an error, we just ignore anything deeper */
if (alternate_depth > GIT_ALTERNATES_MAX_DEPTH) { if (alternate_depth > GIT_ALTERNATES_MAX_DEPTH)
return 0; return 0;
}
if (git_buf_joinpath(&alternates_path, objects_dir, GIT_ALTERNATES_FILE) < 0) if (git_buf_joinpath(&alternates_path, objects_dir, GIT_ALTERNATES_FILE) < 0)
return -1; return -1;
...@@ -687,7 +695,7 @@ int git_odb__read_header_or_object( ...@@ -687,7 +695,7 @@ int git_odb__read_header_or_object(
int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id) int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
{ {
size_t i; size_t i, reads = 0;
int error; int error;
bool refreshed = false; bool refreshed = false;
git_rawobj raw; git_rawobj raw;
...@@ -695,11 +703,6 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id) ...@@ -695,11 +703,6 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
assert(out && db && id); assert(out && db && id);
if (db->backends.length == 0) {
giterr_set(GITERR_ODB, "Failed to lookup object: no backends loaded");
return GIT_ENOTFOUND;
}
*out = git_cache_get_raw(odb_cache(db), id); *out = git_cache_get_raw(odb_cache(db), id);
if (*out != NULL) if (*out != NULL)
return 0; return 0;
...@@ -711,8 +714,10 @@ attempt_lookup: ...@@ -711,8 +714,10 @@ attempt_lookup:
backend_internal *internal = git_vector_get(&db->backends, i); backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend; git_odb_backend *b = internal->backend;
if (b->read != NULL) if (b->read != NULL) {
++reads;
error = b->read(&raw.data, &raw.len, &raw.type, b, id); error = b->read(&raw.data, &raw.len, &raw.type, b, id);
}
} }
if (error == GIT_ENOTFOUND && !refreshed) { if (error == GIT_ENOTFOUND && !refreshed) {
...@@ -723,8 +728,11 @@ attempt_lookup: ...@@ -723,8 +728,11 @@ attempt_lookup:
goto attempt_lookup; goto attempt_lookup;
} }
if (error && error != GIT_PASSTHROUGH) if (error && error != GIT_PASSTHROUGH) {
if (!reads)
return git_odb__error_notfound("no match for id", id);
return error; return error;
}
if ((object = odb_object__alloc(id, &raw)) == NULL) if ((object = odb_object__alloc(id, &raw)) == NULL)
return -1; return -1;
...@@ -844,10 +852,10 @@ int git_odb_write( ...@@ -844,10 +852,10 @@ int git_odb_write(
if (!error || error == GIT_PASSTHROUGH) if (!error || error == GIT_PASSTHROUGH)
return 0; return 0;
/* if no backends were able to write the object directly, we try a streaming /* if no backends were able to write the object directly, we try a
* write to the backends; just write the whole object into the stream in one * streaming write to the backends; just write the whole object into the
* push */ * stream in one push
*/
if ((error = git_odb_open_wstream(&stream, db, len, type)) != 0) if ((error = git_odb_open_wstream(&stream, db, len, type)) != 0)
return error; return error;
...@@ -861,7 +869,7 @@ int git_odb_write( ...@@ -861,7 +869,7 @@ int git_odb_write(
int git_odb_open_wstream( int git_odb_open_wstream(
git_odb_stream **stream, git_odb *db, size_t size, git_otype type) git_odb_stream **stream, git_odb *db, size_t size, git_otype type)
{ {
size_t i; size_t i, writes = 0;
int error = GIT_ERROR; int error = GIT_ERROR;
assert(stream && db); assert(stream && db);
...@@ -874,21 +882,26 @@ int git_odb_open_wstream( ...@@ -874,21 +882,26 @@ int git_odb_open_wstream(
if (internal->is_alternate) if (internal->is_alternate)
continue; continue;
if (b->writestream != NULL) if (b->writestream != NULL) {
++writes;
error = b->writestream(stream, b, size, type); error = b->writestream(stream, b, size, type);
else if (b->write != NULL) } else if (b->write != NULL) {
++writes;
error = init_fake_wstream(stream, b, size, type); error = init_fake_wstream(stream, b, size, type);
}
} }
if (error == GIT_PASSTHROUGH) if (error == GIT_PASSTHROUGH)
error = 0; error = 0;
if (error < 0 && !writes)
error = git_odb__error_unsupported_in_backend("write object");
return error; return error;
} }
int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid) int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid)
{ {
size_t i; size_t i, reads = 0;
int error = GIT_ERROR; int error = GIT_ERROR;
assert(stream && db); assert(stream && db);
...@@ -897,19 +910,23 @@ int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oi ...@@ -897,19 +910,23 @@ int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oi
backend_internal *internal = git_vector_get(&db->backends, i); backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend; git_odb_backend *b = internal->backend;
if (b->readstream != NULL) if (b->readstream != NULL) {
++reads;
error = b->readstream(stream, b, oid); error = b->readstream(stream, b, oid);
}
} }
if (error == GIT_PASSTHROUGH) if (error == GIT_PASSTHROUGH)
error = 0; error = 0;
if (error < 0 && !reads)
error = git_odb__error_unsupported_in_backend("read object streamed");
return error; return error;
} }
int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_transfer_progress_callback progress_cb, void *progress_payload) int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_transfer_progress_callback progress_cb, void *progress_payload)
{ {
size_t i; size_t i, writes = 0;
int error = GIT_ERROR; int error = GIT_ERROR;
assert(out && db); assert(out && db);
...@@ -922,12 +939,16 @@ int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_transfer ...@@ -922,12 +939,16 @@ int git_odb_write_pack(struct git_odb_writepack **out, git_odb *db, git_transfer
if (internal->is_alternate) if (internal->is_alternate)
continue; continue;
if (b->writepack != NULL) if (b->writepack != NULL) {
++writes;
error = b->writepack(out, b, progress_cb, progress_payload); error = b->writepack(out, b, progress_cb, progress_payload);
}
} }
if (error == GIT_PASSTHROUGH) if (error == GIT_PASSTHROUGH)
error = 0; error = 0;
if (error < 0 && !writes)
error = git_odb__error_unsupported_in_backend("write pack");
return error; return error;
} }
......
...@@ -303,7 +303,7 @@ static int revwalk(git_vector *commits, git_push *push) ...@@ -303,7 +303,7 @@ static int revwalk(git_vector *commits, git_push *push)
continue; continue;
if (!git_odb_exists(push->repo->_odb, &spec->roid)) { if (!git_odb_exists(push->repo->_odb, &spec->roid)) {
giterr_clear(); giterr_set(GITERR_REFERENCE, "Cannot push missing reference");
error = GIT_ENONFASTFORWARD; error = GIT_ENONFASTFORWARD;
goto on_error; goto on_error;
} }
...@@ -313,7 +313,8 @@ static int revwalk(git_vector *commits, git_push *push) ...@@ -313,7 +313,8 @@ static int revwalk(git_vector *commits, git_push *push)
if (error == GIT_ENOTFOUND || if (error == GIT_ENOTFOUND ||
(!error && !git_oid_equal(&base, &spec->roid))) { (!error && !git_oid_equal(&base, &spec->roid))) {
giterr_clear(); giterr_set(GITERR_REFERENCE,
"Cannot push non-fastforwardable reference");
error = GIT_ENONFASTFORWARD; error = GIT_ENONFASTFORWARD;
goto on_error; goto on_error;
} }
...@@ -333,12 +334,13 @@ static int revwalk(git_vector *commits, git_push *push) ...@@ -333,12 +334,13 @@ static int revwalk(git_vector *commits, git_push *push)
while ((error = git_revwalk_next(&oid, rw)) == 0) { while ((error = git_revwalk_next(&oid, rw)) == 0) {
git_oid *o = git__malloc(GIT_OID_RAWSZ); git_oid *o = git__malloc(GIT_OID_RAWSZ);
GITERR_CHECK_ALLOC(o); if (!o) {
git_oid_cpy(o, &oid);
if (git_vector_insert(commits, o) < 0) {
error = -1; error = -1;
goto on_error; goto on_error;
} }
git_oid_cpy(o, &oid);
if ((error = git_vector_insert(commits, o)) < 0)
goto on_error;
} }
on_error: on_error:
...@@ -519,7 +521,7 @@ static int calculate_work(git_push *push) ...@@ -519,7 +521,7 @@ static int calculate_work(git_push *push)
/* This is a create or update. Local ref must exist. */ /* This is a create or update. Local ref must exist. */
if (git_reference_name_to_id( if (git_reference_name_to_id(
&spec->loid, push->repo, spec->lref) < 0) { &spec->loid, push->repo, spec->lref) < 0) {
giterr_set(GIT_ENOTFOUND, "No such reference '%s'", spec->lref); giterr_set(GITERR_REFERENCE, "No such reference '%s'", spec->lref);
return -1; return -1;
} }
} }
......
...@@ -483,8 +483,10 @@ int git_reflog_drop( ...@@ -483,8 +483,10 @@ int git_reflog_drop(
entry = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx); entry = (git_reflog_entry *)git_reflog_entry_byindex(reflog, idx);
if (entry == NULL) if (entry == NULL) {
giterr_set(GITERR_REFERENCE, "No reflog entry at index "PRIuZ, idx);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
}
reflog_entry_free(entry); reflog_entry_free(entry);
......
...@@ -844,8 +844,10 @@ static int reference__update_terminal( ...@@ -844,8 +844,10 @@ static int reference__update_terminal(
git_reference *ref; git_reference *ref;
int error = 0; int error = 0;
if (nesting > MAX_NESTING_LEVEL) if (nesting > MAX_NESTING_LEVEL) {
giterr_set(GITERR_REFERENCE, "Reference chain too deep (%d)", nesting);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
}
error = git_reference_lookup(&ref, repo, ref_name); error = git_reference_lookup(&ref, repo, ref_name);
......
...@@ -63,8 +63,10 @@ static int download_tags_value(git_remote *remote, git_config *cfg) ...@@ -63,8 +63,10 @@ static int download_tags_value(git_remote *remote, git_config *cfg)
else if (!error && !strcmp(val, "--tags")) else if (!error && !strcmp(val, "--tags"))
remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL; remote->download_tags = GIT_REMOTE_DOWNLOAD_TAGS_ALL;
if (error == GIT_ENOTFOUND) if (error == GIT_ENOTFOUND) {
giterr_clear();
error = 0; error = 0;
}
return error; return error;
} }
...@@ -210,6 +212,31 @@ static int refspec_cb(const git_config_entry *entry, void *payload) ...@@ -210,6 +212,31 @@ static int refspec_cb(const git_config_entry *entry, void *payload)
return add_refspec(data->remote, entry->value, data->fetch); return add_refspec(data->remote, entry->value, data->fetch);
} }
static int get_optional_config(
git_config *config, git_buf *buf, git_config_foreach_cb cb, void *payload)
{
int error = 0;
const char *key = git_buf_cstr(buf);
if (git_buf_oom(buf))
return -1;
if (cb != NULL)
error = git_config_get_multivar(config, key, NULL, cb, payload);
else
error = git_config_get_string(payload, config, key);
if (error == GIT_ENOTFOUND) {
giterr_clear();
error = 0;
}
if (error < 0)
error = -1;
return error;
}
int git_remote_load(git_remote **out, git_repository *repo, const char *name) int git_remote_load(git_remote **out, git_repository *repo, const char *name)
{ {
git_remote *remote; git_remote *remote;
...@@ -250,7 +277,7 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name) ...@@ -250,7 +277,7 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
if ((error = git_config_get_string(&val, config, git_buf_cstr(&buf))) < 0) if ((error = git_config_get_string(&val, config, git_buf_cstr(&buf))) < 0)
goto cleanup; goto cleanup;
if (strlen(val) == 0) { if (strlen(val) == 0) {
giterr_set(GITERR_INVALID, "Malformed remote '%s' - missing URL", name); giterr_set(GITERR_INVALID, "Malformed remote '%s' - missing URL", name);
error = -1; error = -1;
...@@ -261,60 +288,32 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name) ...@@ -261,60 +288,32 @@ int git_remote_load(git_remote **out, git_repository *repo, const char *name)
remote->url = git__strdup(val); remote->url = git__strdup(val);
GITERR_CHECK_ALLOC(remote->url); GITERR_CHECK_ALLOC(remote->url);
val = NULL;
git_buf_clear(&buf); git_buf_clear(&buf);
if (git_buf_printf(&buf, "remote.%s.pushurl", name) < 0) { git_buf_printf(&buf, "remote.%s.pushurl", name);
error = -1;
goto cleanup;
}
error = git_config_get_string(&val, config, git_buf_cstr(&buf));
if (error == GIT_ENOTFOUND) {
val = NULL;
error = 0;
}
if (error < 0) { if ((error = get_optional_config(config, &buf, NULL, &val)) < 0)
error = -1;
goto cleanup; goto cleanup;
}
if (val) { if (val) {
remote->pushurl = git__strdup(val); remote->pushurl = git__strdup(val);
GITERR_CHECK_ALLOC(remote->pushurl); GITERR_CHECK_ALLOC(remote->pushurl);
} }
git_buf_clear(&buf);
if (git_buf_printf(&buf, "remote.%s.fetch", name) < 0) {
error = -1;
goto cleanup;
}
data.remote = remote; data.remote = remote;
data.fetch = true; data.fetch = true;
error = git_config_get_multivar(config, git_buf_cstr(&buf), NULL, refspec_cb, &data);
if (error == GIT_ENOTFOUND)
error = 0;
if (error < 0) {
error = -1;
goto cleanup;
}
git_buf_clear(&buf); git_buf_clear(&buf);
if (git_buf_printf(&buf, "remote.%s.push", name) < 0) { git_buf_printf(&buf, "remote.%s.fetch", name);
error = -1;
if ((error = get_optional_config(config, &buf, refspec_cb, &data)) < 0)
goto cleanup; goto cleanup;
}
data.fetch = false; data.fetch = false;
error = git_config_get_multivar(config, git_buf_cstr(&buf), NULL, refspec_cb, &data); git_buf_clear(&buf);
if (error == GIT_ENOTFOUND) git_buf_printf(&buf, "remote.%s.push", name);
error = 0;
if (error < 0) { if ((error = get_optional_config(config, &buf, refspec_cb, &data)) < 0)
error = -1;
goto cleanup; goto cleanup;
}
if (download_tags_value(remote, config) < 0) if (download_tags_value(remote, config) < 0)
goto cleanup; goto cleanup;
...@@ -336,7 +335,7 @@ static int update_config_refspec(const git_remote *remote, git_config *config, i ...@@ -336,7 +335,7 @@ static int update_config_refspec(const git_remote *remote, git_config *config, i
int push; int push;
const char *dir; const char *dir;
size_t i; size_t i;
int error = -1; int error = 0;
push = direction == GIT_DIRECTION_PUSH; push = direction == GIT_DIRECTION_PUSH;
dir = push ? "push" : "fetch"; dir = push ? "push" : "fetch";
...@@ -345,9 +344,8 @@ static int update_config_refspec(const git_remote *remote, git_config *config, i ...@@ -345,9 +344,8 @@ static int update_config_refspec(const git_remote *remote, git_config *config, i
return -1; return -1;
/* Clear out the existing config */ /* Clear out the existing config */
do { while (!error)
error = git_config_delete_entry(config, git_buf_cstr(&name)); error = git_config_delete_entry(config, git_buf_cstr(&name));
} while (!error);
if (error != GIT_ENOTFOUND) if (error != GIT_ENOTFOUND)
return error; return error;
...@@ -358,7 +356,8 @@ static int update_config_refspec(const git_remote *remote, git_config *config, i ...@@ -358,7 +356,8 @@ static int update_config_refspec(const git_remote *remote, git_config *config, i
if (spec->push != push) if (spec->push != push)
continue; continue;
if ((error = git_config_set_multivar(config, git_buf_cstr(&name), "", spec->string)) < 0) { if ((error = git_config_set_multivar(
config, git_buf_cstr(&name), "", spec->string)) < 0) {
goto cleanup; goto cleanup;
} }
} }
......
...@@ -1598,6 +1598,7 @@ int git_repository_message(char *buffer, size_t len, git_repository *repo) ...@@ -1598,6 +1598,7 @@ int git_repository_message(char *buffer, size_t len, git_repository *repo)
if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) { if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) {
if (errno == ENOENT) if (errno == ENOENT)
error = GIT_ENOTFOUND; error = GIT_ENOTFOUND;
giterr_set(GITERR_OS, "Could not access message file");
} }
else if (buffer != NULL) { else if (buffer != NULL) {
error = git_futils_readbuffer(&buf, git_buf_cstr(&path)); error = git_futils_readbuffer(&buf, git_buf_cstr(&path));
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
static int disambiguate_refname(git_reference **out, git_repository *repo, const char *refname) static int disambiguate_refname(git_reference **out, git_repository *repo, const char *refname)
{ {
int error = 0, i; int error = 0, i;
bool fallbackmode = true; bool fallbackmode = true, foundvalid = false;
git_reference *ref; git_reference *ref;
git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT; git_buf refnamebuf = GIT_BUF_INIT, name = GIT_BUF_INIT;
...@@ -49,6 +49,7 @@ static int disambiguate_refname(git_reference **out, git_repository *repo, const ...@@ -49,6 +49,7 @@ static int disambiguate_refname(git_reference **out, git_repository *repo, const
error = GIT_EINVALIDSPEC; error = GIT_EINVALIDSPEC;
continue; continue;
} }
foundvalid = true;
error = git_reference_lookup_resolved(&ref, repo, git_buf_cstr(&refnamebuf), -1); error = git_reference_lookup_resolved(&ref, repo, git_buf_cstr(&refnamebuf), -1);
...@@ -63,6 +64,12 @@ static int disambiguate_refname(git_reference **out, git_repository *repo, const ...@@ -63,6 +64,12 @@ static int disambiguate_refname(git_reference **out, git_repository *repo, const
} }
cleanup: cleanup:
if (error && !foundvalid) {
/* never found a valid reference name */
giterr_set(GITERR_REFERENCE,
"Could not use '%s' as valid reference name", git_buf_cstr(&name));
}
git_buf_free(&name); git_buf_free(&name);
git_buf_free(&refnamebuf); git_buf_free(&refnamebuf);
return error; return error;
......
...@@ -587,8 +587,10 @@ int git_stash_foreach( ...@@ -587,8 +587,10 @@ int git_stash_foreach(
const git_reflog_entry *entry; const git_reflog_entry *entry;
error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE); error = git_reference_lookup(&stash, repo, GIT_REFS_STASH_FILE);
if (error == GIT_ENOTFOUND) if (error == GIT_ENOTFOUND) {
giterr_clear();
return 0; return 0;
}
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
...@@ -651,7 +653,7 @@ int git_stash_drop( ...@@ -651,7 +653,7 @@ int git_stash_drop(
const git_reflog_entry *entry; const git_reflog_entry *entry;
entry = git_reflog_entry_byindex(reflog, 0); entry = git_reflog_entry_byindex(reflog, 0);
git_reference_free(stash); git_reference_free(stash);
error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, &entry->oid_cur, 1); error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, &entry->oid_cur, 1);
} }
......
...@@ -141,7 +141,7 @@ int git_status_foreach_ext( ...@@ -141,7 +141,7 @@ int git_status_foreach_ext(
/* if there is no HEAD, that's okay - we'll make an empty iterator */ /* if there is no HEAD, that's okay - we'll make an empty iterator */
if (((err = git_repository_head_tree(&head, repo)) < 0) && if (((err = git_repository_head_tree(&head, repo)) < 0) &&
!(err == GIT_ENOTFOUND || err == GIT_EORPHANEDHEAD)) !(err == GIT_ENOTFOUND || err == GIT_EORPHANEDHEAD))
return err; return err;
memcpy(&diffopt.pathspec, &opts->pathspec, sizeof(diffopt.pathspec)); memcpy(&diffopt.pathspec, &opts->pathspec, sizeof(diffopt.pathspec));
...@@ -238,7 +238,7 @@ static int get_one_status(const char *path, unsigned int status, void *data) ...@@ -238,7 +238,7 @@ static int get_one_status(const char *path, unsigned int status, void *data)
p_fnmatch(sfi->expected, path, sfi->fnm_flags) != 0)) p_fnmatch(sfi->expected, path, sfi->fnm_flags) != 0))
{ {
sfi->ambiguous = true; sfi->ambiguous = true;
return GIT_EAMBIGUOUS; return GIT_EAMBIGUOUS; /* giterr_set will be done by caller */
} }
return 0; return 0;
......
...@@ -128,6 +128,10 @@ int git_submodule_lookup( ...@@ -128,6 +128,10 @@ int git_submodule_lookup(
git_buf_free(&path); git_buf_free(&path);
} }
giterr_set(GITERR_SUBMODULE, (error == GIT_ENOTFOUND) ?
"No submodule named '%s'" :
"Submodule '%s' has not been added yet", name);
return error; return error;
} }
......
...@@ -149,7 +149,7 @@ static int tree_key_search( ...@@ -149,7 +149,7 @@ static int tree_key_search(
/* Initial homing search; find an entry on the tree with /* Initial homing search; find an entry on the tree with
* the same prefix as the filename we're looking for */ * the same prefix as the filename we're looking for */
if (git_vector_bsearch2(&homing, entries, &homing_search_cmp, &ksearch) < 0) if (git_vector_bsearch2(&homing, entries, &homing_search_cmp, &ksearch) < 0)
return GIT_ENOTFOUND; return GIT_ENOTFOUND; /* just a signal error; not passed back to user */
/* We found a common prefix. Look forward as long as /* We found a common prefix. Look forward as long as
* there are entries that share the common prefix */ * there are entries that share the common prefix */
......
...@@ -103,8 +103,3 @@ void test_object_peel__target_any_object_for_type_change(void) ...@@ -103,8 +103,3 @@ void test_object_peel__target_any_object_for_type_change(void)
/* fail to peel blob */ /* fail to peel blob */
assert_peel_error(GIT_ENOTFOUND, "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_ANY); assert_peel_error(GIT_ENOTFOUND, "0266163a49e280c4f5ed1e08facd36a2bd716bcf", GIT_OBJ_ANY);
} }
void test_object_peel__should_use_a_well_known_type(void)
{
assert_peel_error(GIT_EINVALIDSPEC, "7b4384978d2493e851f9cca7858815fac9b10980", GIT_OBJ__EXT2);
}
...@@ -49,16 +49,20 @@ void test_refs_branches_remote__no_matching_remote_returns_error(void) ...@@ -49,16 +49,20 @@ void test_refs_branches_remote__no_matching_remote_returns_error(void)
{ {
const char *unknown = "refs/remotes/nonexistent/master"; const char *unknown = "refs/remotes/nonexistent/master";
giterr_clear();
cl_git_fail_with(git_branch_remote_name( cl_git_fail_with(git_branch_remote_name(
NULL, 0, g_repo, unknown), GIT_ENOTFOUND); NULL, 0, g_repo, unknown), GIT_ENOTFOUND);
cl_assert(giterr_last() != NULL);
} }
void test_refs_branches_remote__local_remote_returns_error(void) void test_refs_branches_remote__local_remote_returns_error(void)
{ {
const char *local = "refs/heads/master"; const char *local = "refs/heads/master";
giterr_clear();
cl_git_fail_with(git_branch_remote_name( cl_git_fail_with(git_branch_remote_name(
NULL, 0, g_repo, local), GIT_ERROR); NULL, 0, g_repo, local), GIT_ERROR);
cl_assert(giterr_last() != NULL);
} }
void test_refs_branches_remote__ambiguous_remote_returns_error(void) void test_refs_branches_remote__ambiguous_remote_returns_error(void)
...@@ -75,6 +79,8 @@ void test_refs_branches_remote__ambiguous_remote_returns_error(void) ...@@ -75,6 +79,8 @@ void test_refs_branches_remote__ambiguous_remote_returns_error(void)
git_remote_free(remote); git_remote_free(remote);
giterr_clear();
cl_git_fail_with(git_branch_remote_name(NULL, 0, g_repo, cl_git_fail_with(git_branch_remote_name(NULL, 0, g_repo,
remote_tracking_branch_name), GIT_EAMBIGUOUS); remote_tracking_branch_name), GIT_EAMBIGUOUS);
cl_assert(giterr_last() != NULL);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment