vendor/libgit2/src/patch.c in rugged-1.1.1 vs vendor/libgit2/src/patch.c in rugged-1.2.0
- old
+ new
@@ -63,11 +63,11 @@
int include_hunk_headers,
int include_file_headers)
{
size_t out;
- assert(patch);
+ GIT_ASSERT_ARG(patch);
out = patch->content_size;
if (!include_context)
out -= patch->context_size;
@@ -127,17 +127,17 @@
return 0;
}
const git_diff_delta *git_patch_get_delta(const git_patch *patch)
{
- assert(patch);
+ GIT_ASSERT_ARG_WITH_RETVAL(patch, NULL);
return patch->delta;
}
size_t git_patch_num_hunks(const git_patch *patch)
{
- assert(patch);
+ GIT_ASSERT_ARG(patch);
return git_array_size(patch->hunks);
}
static int patch_error_outofrange(const char *thing)
{
@@ -150,11 +150,11 @@
size_t *lines_in_hunk,
git_patch *patch,
size_t hunk_idx)
{
git_patch_hunk *hunk;
- assert(patch);
+ GIT_ASSERT_ARG(patch);
hunk = git_array_get(patch->hunks, hunk_idx);
if (!hunk) {
if (out) *out = NULL;
@@ -168,11 +168,11 @@
}
int git_patch_num_lines_in_hunk(const git_patch *patch, size_t hunk_idx)
{
git_patch_hunk *hunk;
- assert(patch);
+ GIT_ASSERT_ARG(patch);
if (!(hunk = git_array_get(patch->hunks, hunk_idx)))
return patch_error_outofrange("hunk");
return (int)hunk->line_count;
}
@@ -184,11 +184,11 @@
size_t line_of_hunk)
{
git_patch_hunk *hunk;
git_diff_line *line;
- assert(patch);
+ GIT_ASSERT_ARG(patch);
if (!(hunk = git_array_get(patch->hunks, hunk_idx))) {
if (out) *out = NULL;
return patch_error_outofrange("hunk");
}
@@ -202,12 +202,19 @@
if (out) *out = line;
return 0;
}
+git_repository *git_patch_owner(const git_patch *patch)
+{
+ return patch->repo;
+}
+
int git_patch_from_diff(git_patch **out, git_diff *diff, size_t idx)
{
- assert(out && diff && diff->patch_fn);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(diff);
+ GIT_ASSERT_ARG(diff->patch_fn);
return diff->patch_fn(out, diff, idx);
}
static void git_patch__free(git_patch *patch)
{