apply: use GIT_ASSERT
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/src/apply.c b/src/apply.c
index b0be2d8..7c65cd7 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -5,8 +5,6 @@
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "apply.h"
-
#include "git2/apply.h"
#include "git2/patch.h"
#include "git2/filter.h"
@@ -21,6 +19,7 @@
#include "zstream.h"
#include "reader.h"
#include "index.h"
+#include "apply.h"
typedef struct {
/* The lines that we allocate ourself are allocated out of the pool.
@@ -399,7 +398,11 @@ int git_apply__patch(
unsigned int mode = 0;
int error = 0;
- assert(contents_out && filename_out && mode_out && (source || !source_len) && patch);
+ GIT_ASSERT_ARG(contents_out);
+ GIT_ASSERT_ARG(filename_out);
+ GIT_ASSERT_ARG(mode_out);
+ GIT_ASSERT_ARG(source || !source_len);
+ GIT_ASSERT_ARG(patch);
if (given_opts)
memcpy(&ctx.opts, given_opts, sizeof(git_apply_options));
@@ -624,7 +627,10 @@ int git_apply_to_tree(
size_t i;
int error = 0;
- assert(out && repo && preimage && diff);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(preimage);
+ GIT_ASSERT_ARG(diff);
*out = NULL;
@@ -772,6 +778,8 @@ done:
int git_apply_options_init(git_apply_options *opts, unsigned int version)
{
+ GIT_ASSERT_ARG(opts);
+
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_apply_options, GIT_APPLY_OPTIONS_INIT);
return 0;
@@ -805,7 +813,8 @@ int git_apply(
git_apply_options opts = GIT_APPLY_OPTIONS_INIT;
int error = GIT_EINVALID;
- assert(repo && diff);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(diff);
GIT_ERROR_CHECK_VERSION(
given_opts, GIT_APPLY_OPTIONS_VERSION, "git_apply_options");
@@ -829,7 +838,7 @@ int git_apply(
error = git_reader_for_workdir(&pre_reader, repo, false);
break;
default:
- assert(false);
+ GIT_ASSERT(false);
}
if (error < 0)
@@ -869,7 +878,7 @@ int git_apply(
error = git_apply__to_workdir(repo, diff, preimage, postimage, location, &opts);
break;
default:
- assert(false);
+ GIT_ASSERT(false);
}
if (error < 0)