Commit 0afe9996 by Ben Straub

Check errors from libgit2 calls

parent 4c7fdb4d
...@@ -374,9 +374,9 @@ static struct origin* find_origin(struct scoreboard *sb, git_commit *parent, ...@@ -374,9 +374,9 @@ static struct origin* find_origin(struct scoreboard *sb, git_commit *parent,
git_tree *otree=NULL, *ptree=NULL; git_tree *otree=NULL, *ptree=NULL;
/* Get the trees from this commit and its parent */ /* Get the trees from this commit and its parent */
// TODO: check errors if (0 != git_commit_tree(&otree, origin->commit) ||
git_commit_tree(&otree, origin->commit); 0 != git_commit_tree(&ptree, parent))
git_commit_tree(&ptree, parent); goto cleanup;
/* Configure the diff */ /* Configure the diff */
diffopts.context_lines = 0; diffopts.context_lines = 0;
...@@ -385,12 +385,11 @@ static struct origin* find_origin(struct scoreboard *sb, git_commit *parent, ...@@ -385,12 +385,11 @@ static struct origin* find_origin(struct scoreboard *sb, git_commit *parent,
/* Check to see if files we're interested have changed */ /* Check to see if files we're interested have changed */
diffopts.pathspec.count = sb->blame->paths.length; diffopts.pathspec.count = sb->blame->paths.length;
diffopts.pathspec.strings = (char**)sb->blame->paths.contents; diffopts.pathspec.strings = (char**)sb->blame->paths.contents;
// TODO: check error if (0 != git_diff_tree_to_tree(&difflist, sb->blame->repository, ptree, otree, &diffopts))
git_diff_tree_to_tree(&difflist, sb->blame->repository, ptree, otree, &diffopts); goto cleanup;
if (!git_diff_num_deltas(difflist)) { if (!git_diff_num_deltas(difflist)) {
/* No changes; copy data */ /* No changes; copy data */
// TODO: check error
get_origin(&porigin, sb, parent, origin->path); get_origin(&porigin, sb, parent, origin->path);
} else { } else {
git_diff_find_options findopts = GIT_DIFF_FIND_OPTIONS_INIT; git_diff_find_options findopts = GIT_DIFF_FIND_OPTIONS_INIT;
...@@ -399,13 +398,13 @@ static struct origin* find_origin(struct scoreboard *sb, git_commit *parent, ...@@ -399,13 +398,13 @@ static struct origin* find_origin(struct scoreboard *sb, git_commit *parent,
/* Generate a full diff between the two trees */ /* Generate a full diff between the two trees */
git_diff_list_free(difflist); git_diff_list_free(difflist);
diffopts.pathspec.count = 0; diffopts.pathspec.count = 0;
// TODO: check error if (0 != git_diff_tree_to_tree(&difflist, sb->blame->repository, ptree, otree, &diffopts))
git_diff_tree_to_tree(&difflist, sb->blame->repository, ptree, otree, &diffopts); goto cleanup;
/* Let diff find renames */ /* Let diff find renames */
findopts.flags = GIT_DIFF_FIND_RENAMES; findopts.flags = GIT_DIFF_FIND_RENAMES;
// TODO: check error if (0 != git_diff_find_similar(difflist, &findopts))
git_diff_find_similar(difflist, &findopts); goto cleanup;
/* Find one that matches */ /* Find one that matches */
for (i=0; i<(int)git_diff_num_deltas(difflist); i++) { for (i=0; i<(int)git_diff_num_deltas(difflist); i++) {
...@@ -415,16 +414,15 @@ static struct origin* find_origin(struct scoreboard *sb, git_commit *parent, ...@@ -415,16 +414,15 @@ static struct origin* find_origin(struct scoreboard *sb, git_commit *parent,
continue; continue;
git_vector_insert_sorted(&sb->blame->paths, (void*)git__strdup(delta->old_file.path), paths_on_dup); git_vector_insert_sorted(&sb->blame->paths, (void*)git__strdup(delta->old_file.path), paths_on_dup);
// TODO: check error
make_origin(&porigin, parent, delta->old_file.path); make_origin(&porigin, parent, delta->old_file.path);
} }
} }
cleanup:
git_diff_list_free(difflist); git_diff_list_free(difflist);
git_tree_free(otree); git_tree_free(otree);
git_tree_free(ptree); git_tree_free(ptree);
return porigin; return porigin;
} }
/* /*
...@@ -472,7 +470,6 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, uint32_t op ...@@ -472,7 +470,6 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, uint32_t op
if (sg_origin[i]) if (sg_origin[i])
continue; continue;
// TODO: check error
git_commit_parent(&p, origin->commit, i); git_commit_parent(&p, origin->commit, i);
porigin = find_origin(sb, p, origin); porigin = find_origin(sb, p, origin);
......
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