merge: 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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
diff --git a/src/merge.c b/src/merge.c
index 2f6bf6f..e02ea91 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -139,7 +139,9 @@ int git_merge_base_many(git_oid *out, git_repository *repo, size_t length, const
git_commit_list *result = NULL;
int error = 0;
- assert(out && repo && input_array);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(input_array);
if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0)
return error;
@@ -159,7 +161,9 @@ int git_merge_bases_many(git_oidarray *out, git_repository *repo, size_t length,
int error = 0;
git_array_oid_t array;
- assert(out && repo && input_array);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(input_array);
if ((error = merge_bases_many(&result, &walk, repo, length, input_array)) < 0)
return error;
@@ -193,7 +197,9 @@ int git_merge_base_octopus(git_oid *out, git_repository *repo, size_t length, co
unsigned int i;
int error = -1;
- assert(out && repo && input_array);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(input_array);
if (length < 2) {
git_error_set(GIT_ERROR_INVALID, "at least two commits are required to find an ancestor");
@@ -581,7 +587,8 @@ int git_repository_mergehead_foreach(
git_oid oid;
int error = 0;
- assert(repo && cb);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(cb);
if ((error = git_buf_joinpath(&merge_head_path, repo->gitdir,
GIT_MERGE_HEAD_FILE)) < 0)
@@ -650,7 +657,9 @@ static int merge_conflict_resolve_trivial(
git_index_entry const *result = NULL;
int error = 0;
- assert(resolved && diff_list && conflict);
+ GIT_ASSERT_ARG(resolved);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(conflict);
*resolved = 0;
@@ -733,7 +742,9 @@ static int merge_conflict_resolve_one_removed(
int ours_changed, theirs_changed;
int error = 0;
- assert(resolved && diff_list && conflict);
+ GIT_ASSERT_ARG(resolved);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(conflict);
*resolved = 0;
@@ -773,7 +784,9 @@ static int merge_conflict_resolve_one_renamed(
git_index_entry *merged;
int error = 0;
- assert(resolved && diff_list && conflict);
+ GIT_ASSERT_ARG(resolved);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(conflict);
*resolved = 0;
@@ -917,7 +930,9 @@ static int merge_conflict_resolve_contents(
bool fallback = false;
int error;
- assert(resolved && diff_list && conflict);
+ GIT_ASSERT_ARG(resolved);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(conflict);
*resolved = 0;
@@ -1517,7 +1532,8 @@ int git_merge_diff_list__find_renames(
size_t src_count, tgt_count, i;
int error = 0;
- assert(diff_list && opts);
+ GIT_ASSERT_ARG(diff_list);
+ GIT_ASSERT_ARG(opts);
if ((opts->flags & GIT_MERGE_FIND_RENAMES) == 0)
return 0;
@@ -1843,7 +1859,8 @@ static int merge_normalize_opts(
git_config_entry *entry = NULL;
int error = 0;
- assert(repo && opts);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(opts);
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
return error;
@@ -2070,7 +2087,8 @@ int git_merge__iterators(
size_t i;
int error = 0;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
*out = NULL;
@@ -2154,7 +2172,8 @@ int git_merge_trees(
git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT;
int error;
- assert(out && repo);
+ GIT_ASSERT_ARG(out);
+ GIT_ASSERT_ARG(repo);
/* if one side is treesame to the ancestor, take the other side */
if (ancestor_tree && merge_opts && (merge_opts->flags & GIT_MERGE_SKIP_REUC)) {
@@ -2441,7 +2460,8 @@ static int write_merge_head(
size_t i;
int error = 0;
- assert(repo && heads);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(heads);
if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_HEAD_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_MERGE_FILE_MODE)) < 0)
@@ -2469,7 +2489,7 @@ static int write_merge_mode(git_repository *repo)
git_buf file_path = GIT_BUF_INIT;
int error = 0;
- assert(repo);
+ GIT_ASSERT_ARG(repo);
if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_MERGE_MODE_FILE)) < 0 ||
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_MERGE_FILE_MODE)) < 0)
@@ -2689,7 +2709,8 @@ static int write_merge_msg(
char sep = 0;
int error = 0;
- assert(repo && heads);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(heads);
entries = git__calloc(heads_len, sizeof(struct merge_msg_entry));
GIT_ERROR_CHECK_ALLOC(entries);
@@ -2800,7 +2821,9 @@ int git_merge__setup(
{
int error = 0;
- assert (repo && our_head && heads);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(our_head);
+ GIT_ASSERT_ARG(heads);
if ((error = git_repository__set_orig_head(repo, git_annotated_commit_id(our_head))) == 0 &&
(error = write_merge_head(repo, heads, heads_len)) == 0 &&
@@ -2824,7 +2847,9 @@ static int merge_ancestor_head(
size_t i, alloc_len;
int error = 0;
- assert(repo && our_head && their_heads);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(our_head);
+ GIT_ASSERT_ARG(their_heads);
GIT_ERROR_CHECK_ALLOC_ADD(&alloc_len, their_heads_len, 1);
oids = git__calloc(alloc_len, sizeof(git_oid));
@@ -3202,7 +3227,10 @@ int git_merge_analysis_for_ref(
int error = 0;
bool unborn;
- assert(analysis_out && preference_out && repo && their_heads && their_heads_len > 0);
+ GIT_ASSERT_ARG(analysis_out);
+ GIT_ASSERT_ARG(preference_out);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(their_heads && their_heads_len > 0);
if (their_heads_len != 1) {
git_error_set(GIT_ERROR_MERGE, "can only merge a single branch");
@@ -3284,7 +3312,8 @@ int git_merge(
unsigned int checkout_strategy;
int error = 0;
- assert(repo && their_heads && their_heads_len > 0);
+ GIT_ASSERT_ARG(repo);
+ GIT_ASSERT_ARG(their_heads && their_heads_len > 0);
if (their_heads_len != 1) {
git_error_set(GIT_ERROR_MERGE, "can only merge a single branch");