@@ -142,7 +142,7 @@ static void set_index(git_repository *repo, git_index *index)
142142
143143int git_repository__cleanup (git_repository * repo )
144144{
145- assert (repo );
145+ GIT_ASSERT_ARG (repo );
146146
147147 git_repository_submodule_cache_clear (repo );
148148 git_cache_clear (& repo -> objects );
@@ -368,7 +368,7 @@ static size_t find_ceiling_dir_offset(
368368 const char * ceil , * sep ;
369369 size_t len , max_len = 0 , min_len ;
370370
371- assert (path );
371+ GIT_ASSERT_ARG (path );
372372
373373 min_len = (size_t )(git_path_root (path ) + 1 );
374374
@@ -414,7 +414,8 @@ static int read_gitfile(git_buf *path_out, const char *file_path)
414414 git_buf file = GIT_BUF_INIT ;
415415 size_t prefix_len = strlen (GIT_FILE_CONTENT_PREFIX );
416416
417- assert (path_out && file_path );
417+ GIT_ASSERT_ARG (path_out );
418+ GIT_ASSERT_ARG (file_path );
418419
419420 if (git_futils_readbuffer (& file , file_path ) < 0 )
420421 return -1 ;
@@ -901,7 +902,8 @@ int git_repository_open_from_worktree(git_repository **repo_out, git_worktree *w
901902 size_t len ;
902903 int err ;
903904
904- assert (repo_out && wt );
905+ GIT_ASSERT_ARG (repo_out );
906+ GIT_ASSERT_ARG (wt );
905907
906908 * repo_out = NULL ;
907909 len = strlen (wt -> gitlink_path );
@@ -947,7 +949,7 @@ int git_repository_discover(
947949 uint32_t flags = across_fs ? GIT_REPOSITORY_OPEN_CROSS_FS : 0 ;
948950 int error ;
949951
950- assert (start_path );
952+ GIT_ASSERT_ARG (start_path );
951953
952954 if ((error = git_buf_sanitize (out )) < 0 )
953955 return error ;
@@ -967,7 +969,7 @@ static int load_config(
967969 git_buf config_path = GIT_BUF_INIT ;
968970 git_config * cfg = NULL ;
969971
970- assert (out );
972+ GIT_ASSERT_ARG (out );
971973
972974 if ((error = git_config_new (& cfg )) < 0 )
973975 return error ;
@@ -1091,7 +1093,9 @@ int git_repository_config_snapshot(git_config **out, git_repository *repo)
10911093
10921094int git_repository_set_config (git_repository * repo , git_config * config )
10931095{
1094- assert (repo && config );
1096+ GIT_ASSERT_ARG (repo );
1097+ GIT_ASSERT_ARG (config );
1098+
10951099 set_config (repo , config );
10961100 return 0 ;
10971101}
@@ -1100,7 +1104,8 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
11001104{
11011105 int error = 0 ;
11021106
1103- assert (repo && out );
1107+ GIT_ASSERT_ARG (repo );
1108+ GIT_ASSERT_ARG (out );
11041109
11051110 if (repo -> _odb == NULL ) {
11061111 git_buf odb_path = GIT_BUF_INIT ;
@@ -1143,7 +1148,9 @@ int git_repository_odb(git_odb **out, git_repository *repo)
11431148
11441149int git_repository_set_odb (git_repository * repo , git_odb * odb )
11451150{
1146- assert (repo && odb );
1151+ GIT_ASSERT_ARG (repo );
1152+ GIT_ASSERT_ARG (odb );
1153+
11471154 set_odb (repo , odb );
11481155 return 0 ;
11491156}
@@ -1152,7 +1159,8 @@ int git_repository_refdb__weakptr(git_refdb **out, git_repository *repo)
11521159{
11531160 int error = 0 ;
11541161
1155- assert (out && repo );
1162+ GIT_ASSERT_ARG (out );
1163+ GIT_ASSERT_ARG (repo );
11561164
11571165 if (repo -> _refdb == NULL ) {
11581166 git_refdb * refdb ;
@@ -1184,7 +1192,9 @@ int git_repository_refdb(git_refdb **out, git_repository *repo)
11841192
11851193int git_repository_set_refdb (git_repository * repo , git_refdb * refdb )
11861194{
1187- assert (repo && refdb );
1195+ GIT_ASSERT_ARG (repo );
1196+ GIT_ASSERT_ARG (refdb );
1197+
11881198 set_refdb (repo , refdb );
11891199 return 0 ;
11901200}
@@ -1193,7 +1203,8 @@ int git_repository_index__weakptr(git_index **out, git_repository *repo)
11931203{
11941204 int error = 0 ;
11951205
1196- assert (out && repo );
1206+ GIT_ASSERT_ARG (out );
1207+ GIT_ASSERT_ARG (repo );
11971208
11981209 if (repo -> _index == NULL ) {
11991210 git_buf index_path = GIT_BUF_INIT ;
@@ -1234,7 +1245,7 @@ int git_repository_index(git_index **out, git_repository *repo)
12341245
12351246int git_repository_set_index (git_repository * repo , git_index * index )
12361247{
1237- assert (repo );
1248+ GIT_ASSERT_ARG (repo );
12381249 set_index (repo , index );
12391250 return 0 ;
12401251}
@@ -2132,7 +2143,9 @@ int git_repository_init_ext(
21322143 bool is_valid ;
21332144 int error ;
21342145
2135- assert (out && given_repo && opts );
2146+ GIT_ASSERT_ARG (out );
2147+ GIT_ASSERT_ARG (given_repo );
2148+ GIT_ASSERT_ARG (opts );
21362149
21372150 GIT_ERROR_CHECK_VERSION (opts , GIT_REPOSITORY_INIT_OPTIONS_VERSION , "git_repository_init_options" );
21382151
@@ -2208,7 +2221,8 @@ int git_repository_head_detached_for_worktree(git_repository *repo, const char *
22082221 git_reference * ref = NULL ;
22092222 int error ;
22102223
2211- assert (repo && name );
2224+ GIT_ASSERT_ARG (repo );
2225+ GIT_ASSERT_ARG (name );
22122226
22132227 if ((error = git_repository_head_for_worktree (& ref , repo , name )) < 0 )
22142228 goto out ;
@@ -2225,7 +2239,7 @@ int git_repository_head(git_reference **head_out, git_repository *repo)
22252239 git_reference * head ;
22262240 int error ;
22272241
2228- assert (head_out );
2242+ GIT_ASSERT_ARG (head_out );
22292243
22302244 if ((error = git_reference_lookup (& head , repo , GIT_HEAD_FILE )) < 0 )
22312245 return error ;
@@ -2248,7 +2262,9 @@ int git_repository_head_for_worktree(git_reference **out, git_repository *repo,
22482262 git_reference * head = NULL ;
22492263 int error ;
22502264
2251- assert (out && repo && name );
2265+ GIT_ASSERT_ARG (out );
2266+ GIT_ASSERT_ARG (repo );
2267+ GIT_ASSERT_ARG (name );
22522268
22532269 * out = NULL ;
22542270
@@ -2462,13 +2478,13 @@ int git_repository_item_path(git_buf *out, const git_repository *repo, git_repos
24622478
24632479const char * git_repository_path (const git_repository * repo )
24642480{
2465- assert (repo );
2481+ GIT_ASSERT_ARG_WITH_RETVAL (repo , NULL );
24662482 return repo -> gitdir ;
24672483}
24682484
24692485const char * git_repository_workdir (const git_repository * repo )
24702486{
2471- assert (repo );
2487+ GIT_ASSERT_ARG_WITH_RETVAL (repo , NULL );
24722488
24732489 if (repo -> is_bare )
24742490 return NULL ;
@@ -2478,7 +2494,7 @@ const char *git_repository_workdir(const git_repository *repo)
24782494
24792495const char * git_repository_commondir (const git_repository * repo )
24802496{
2481- assert (repo );
2497+ GIT_ASSERT_ARG_WITH_RETVAL (repo , NULL );
24822498 return repo -> commondir ;
24832499}
24842500
@@ -2488,7 +2504,8 @@ int git_repository_set_workdir(
24882504 int error = 0 ;
24892505 git_buf path = GIT_BUF_INIT ;
24902506
2491- assert (repo && workdir );
2507+ GIT_ASSERT_ARG (repo );
2508+ GIT_ASSERT_ARG (workdir );
24922509
24932510 if (git_path_prettify_dir (& path , workdir , NULL ) < 0 )
24942511 return -1 ;
@@ -2528,13 +2545,13 @@ int git_repository_set_workdir(
25282545
25292546int git_repository_is_bare (const git_repository * repo )
25302547{
2531- assert (repo );
2548+ GIT_ASSERT_ARG (repo );
25322549 return repo -> is_bare ;
25332550}
25342551
25352552int git_repository_is_worktree (const git_repository * repo )
25362553{
2537- assert (repo );
2554+ GIT_ASSERT_ARG (repo );
25382555 return repo -> is_worktree ;
25392556}
25402557
@@ -2543,7 +2560,7 @@ int git_repository_set_bare(git_repository *repo)
25432560 int error ;
25442561 git_config * config ;
25452562
2546- assert (repo );
2563+ GIT_ASSERT_ARG (repo );
25472564
25482565 if (repo -> is_bare )
25492566 return 0 ;
@@ -2657,7 +2674,10 @@ int git_repository_hashfile(
26572674 uint64_t len ;
26582675 git_buf full_path = GIT_BUF_INIT ;
26592676
2660- assert (out && path && repo ); /* as_path can be NULL */
2677+ /* as_path can be NULL */
2678+ GIT_ASSERT_ARG (out );
2679+ GIT_ASSERT_ARG (path );
2680+ GIT_ASSERT_ARG (repo );
26612681
26622682 /* At some point, it would be nice if repo could be NULL to just
26632683 * apply filter rules defined in system and global files, but for
@@ -2742,7 +2762,8 @@ static int detach(git_repository *repo, const git_oid *id, const char *new)
27422762 git_object * object = NULL , * peeled = NULL ;
27432763 git_reference * new_head = NULL , * current = NULL ;
27442764
2745- assert (repo && id );
2765+ GIT_ASSERT_ARG (repo );
2766+ GIT_ASSERT_ARG (id );
27462767
27472768 if ((error = git_reference_lookup (& current , repo , GIT_HEAD_FILE )) < 0 )
27482769 return error ;
@@ -2778,7 +2799,8 @@ int git_repository_set_head(
27782799 git_buf log_message = GIT_BUF_INIT ;
27792800 int error ;
27802801
2781- assert (repo && refname );
2802+ GIT_ASSERT_ARG (repo );
2803+ GIT_ASSERT_ARG (refname );
27822804
27832805 if ((error = git_reference_lookup (& current , repo , GIT_HEAD_FILE )) < 0 )
27842806 return error ;
@@ -2830,7 +2852,8 @@ int git_repository_set_head_detached_from_annotated(
28302852 git_repository * repo ,
28312853 const git_annotated_commit * commitish )
28322854{
2833- assert (repo && commitish );
2855+ GIT_ASSERT_ARG (repo );
2856+ GIT_ASSERT_ARG (commitish );
28342857
28352858 return detach (repo , git_annotated_commit_id (commitish ), commitish -> description );
28362859}
@@ -2842,7 +2865,7 @@ int git_repository_detach_head(git_repository* repo)
28422865 git_buf log_message = GIT_BUF_INIT ;
28432866 int error ;
28442867
2845- assert (repo );
2868+ GIT_ASSERT_ARG (repo );
28462869
28472870 if ((error = git_reference_lookup (& current , repo , GIT_HEAD_FILE )) < 0 )
28482871 return error ;
@@ -2877,7 +2900,7 @@ int git_repository_state(git_repository *repo)
28772900 git_buf repo_path = GIT_BUF_INIT ;
28782901 int state = GIT_REPOSITORY_STATE_NONE ;
28792902
2880- assert (repo );
2903+ GIT_ASSERT_ARG (repo );
28812904
28822905 if (git_buf_puts (& repo_path , repo -> gitdir ) < 0 )
28832906 return -1 ;
@@ -2954,7 +2977,7 @@ static const char *state_files[] = {
29542977
29552978int git_repository_state_cleanup (git_repository * repo )
29562979{
2957- assert (repo );
2980+ GIT_ASSERT_ARG (repo );
29582981
29592982 return git_repository__cleanup_files (repo , state_files , ARRAY_SIZE (state_files ));
29602983}
@@ -3033,7 +3056,7 @@ int git_repository_submodule_cache_all(git_repository *repo)
30333056{
30343057 int error ;
30353058
3036- assert (repo );
3059+ GIT_ASSERT_ARG (repo );
30373060
30383061 if ((error = git_strmap_new (& repo -> submodule_cache )))
30393062 return error ;
@@ -3045,7 +3068,9 @@ int git_repository_submodule_cache_all(git_repository *repo)
30453068int git_repository_submodule_cache_clear (git_repository * repo )
30463069{
30473070 git_submodule * sm ;
3048- assert (repo );
3071+
3072+ GIT_ASSERT_ARG (repo );
3073+
30493074 if (repo -> submodule_cache == NULL ) {
30503075 return 0 ;
30513076 }
0 commit comments