Commit 3cf11eef by Russell Belfer

Misc cleanups

parent c0644c3f
......@@ -49,6 +49,8 @@ int git_attr_get(
git_attr_name attr;
git_attr_rule *rule;
assert(value && repo && name);
*value = NULL;
if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
......@@ -103,6 +105,11 @@ int git_attr_get_many(
attr_get_many_info *info = NULL;
size_t num_found = 0;
if (!num_attr)
return 0;
assert(values && repo && names);
if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
return -1;
......@@ -169,6 +176,8 @@ int git_attr_foreach(
git_attr_assignment *assign;
git_strmap *seen = NULL;
assert(repo && callback);
if (git_attr_path__init(&path, pathname, git_repository_workdir(repo)) < 0)
return -1;
......
......@@ -21,27 +21,22 @@ static int retrieve_branch_reference(
const char *branch_name,
int is_remote)
{
git_reference *branch;
int error = -1;
git_reference *branch = NULL;
int error = 0;
char *prefix;
git_buf ref_name = GIT_BUF_INIT;
*branch_reference_out = NULL;
prefix = is_remote ? GIT_REFS_REMOTES_DIR : GIT_REFS_HEADS_DIR;
if (git_buf_joinpath(&ref_name, prefix, branch_name) < 0)
goto cleanup;
if ((error = git_buf_joinpath(&ref_name, prefix, branch_name)) < 0)
/* OOM */;
else if ((error = git_reference_lookup(&branch, repo, ref_name.ptr)) < 0)
giterr_set(
GITERR_REFERENCE, "Cannot locate %s branch '%s'",
is_remote ? "remote-tracking" : "local", branch_name);
if ((error = git_reference_lookup(&branch, repo, ref_name.ptr)) < 0) {
giterr_set(GITERR_REFERENCE,
"Cannot locate %s branch '%s'.", is_remote ? "remote-tracking" : "local", branch_name);
goto cleanup;
}
*branch_reference_out = branch; /* will be NULL on error */
*branch_reference_out = branch;
cleanup:
git_buf_free(&ref_name);
return error;
}
......@@ -63,21 +58,19 @@ int git_branch_create(
{
git_reference *branch = NULL;
git_buf canonical_branch_name = GIT_BUF_INIT;
int error = -1;
int error = 0;
assert(branch_name && commit && ref_out);
assert(git_object_owner((const git_object *)commit) == repository);
if (git_buf_joinpath(&canonical_branch_name, GIT_REFS_HEADS_DIR, branch_name) < 0)
goto cleanup;
error = git_reference_create(&branch, repository,
git_buf_cstr(&canonical_branch_name), git_commit_id(commit), force, NULL, NULL);
if (!(error = git_buf_joinpath(
&canonical_branch_name, GIT_REFS_HEADS_DIR, branch_name)))
error = git_reference_create(
&branch, repository, git_buf_cstr(&canonical_branch_name),
git_commit_id(commit), force, NULL, NULL);
if (!error)
*ref_out = branch;
*ref_out = branch;
cleanup:
git_buf_free(&canonical_branch_name);
return error;
}
......
......@@ -560,7 +560,6 @@ void test_status_renames__zero_byte_file_does_not_fail(void)
{
git_status_list *statuslist;
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
status_entry_counts counts = {0};
struct status_entry expected[] = {
{ GIT_STATUS_WT_DELETED, "ikeepsix.txt", "ikeepsix.txt" },
......
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