@@ -258,7 +258,8 @@ int git_submodule_lookup(
258258 unsigned int location ;
259259 git_submodule * sm ;
260260
261- assert (repo && name );
261+ GIT_ASSERT_ARG (repo );
262+ GIT_ASSERT_ARG (name );
262263
263264 if (repo -> is_bare ) {
264265 git_error_set (GIT_ERROR_SUBMODULE , "cannot get submodules without a working tree" );
@@ -520,7 +521,8 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
520521 git_submodule * sm ;
521522 git_config * mods = NULL ;
522523
523- assert (repo && map );
524+ GIT_ASSERT_ARG (repo );
525+ GIT_ASSERT_ARG (map );
524526
525527 /* get sources that we will need to check */
526528 if (git_repository_index (& idx , repo ) < 0 )
@@ -698,7 +700,9 @@ int git_submodule_add_setup(
698700 git_repository * subrepo = NULL ;
699701 bool path_occupied ;
700702
701- assert (repo && url && path );
703+ GIT_ASSERT_ARG (repo );
704+ GIT_ASSERT_ARG (url );
705+ GIT_ASSERT_ARG (path );
702706
703707 /* see if there is already an entry for this submodule */
704708
@@ -799,7 +803,8 @@ int git_submodule_repo_init(
799803 git_config * cfg = NULL ;
800804 git_buf buf = GIT_BUF_INIT ;
801805
802- assert (out && sm );
806+ GIT_ASSERT_ARG (out );
807+ GIT_ASSERT_ARG (sm );
803808
804809 /* get the configured remote url of the submodule */
805810 if ((error = git_buf_printf (& buf , "submodule.%s.url" , sm -> name )) < 0 ||
@@ -840,7 +845,7 @@ int git_submodule_clone(git_repository **out, git_submodule *submodule, const gi
840845 git_submodule_update_options sub_opts = GIT_SUBMODULE_UPDATE_OPTIONS_INIT ;
841846 git_clone_options opts = GIT_CLONE_OPTIONS_INIT ;
842847
843- assert (submodule );
848+ GIT_ASSERT_ARG (submodule );
844849
845850 if (given_opts )
846851 memcpy (& sub_opts , given_opts , sizeof (sub_opts ));
@@ -879,7 +884,7 @@ int git_submodule_add_finalize(git_submodule *sm)
879884 int error ;
880885 git_index * index ;
881886
882- assert (sm );
887+ GIT_ASSERT_ARG (sm );
883888
884889 if ((error = git_repository_index__weakptr (& index , sm -> repo )) < 0 ||
885890 (error = git_index_add_bypath (index , GIT_MODULES_FILE )) < 0 )
@@ -898,7 +903,7 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
898903 git_index_entry entry ;
899904 struct stat st ;
900905
901- assert (sm );
906+ GIT_ASSERT_ARG (sm );
902907
903908 /* force reload of wd OID by git_submodule_open */
904909 sm -> flags = sm -> flags & ~GIT_SUBMODULE_STATUS__WD_OID_VALID ;
@@ -969,25 +974,25 @@ static const char *submodule_update_to_str(git_submodule_update_t update)
969974
970975git_repository * git_submodule_owner (git_submodule * submodule )
971976{
972- assert (submodule );
977+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , NULL );
973978 return submodule -> repo ;
974979}
975980
976981const char * git_submodule_name (git_submodule * submodule )
977982{
978- assert (submodule );
983+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , NULL );
979984 return submodule -> name ;
980985}
981986
982987const char * git_submodule_path (git_submodule * submodule )
983988{
984- assert (submodule );
989+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , NULL );
985990 return submodule -> path ;
986991}
987992
988993const char * git_submodule_url (git_submodule * submodule )
989994{
990- assert (submodule );
995+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , NULL );
991996 return submodule -> url ;
992997}
993998
@@ -996,7 +1001,9 @@ int git_submodule_resolve_url(git_buf *out, git_repository *repo, const char *ur
9961001 int error = 0 ;
9971002 git_buf normalized = GIT_BUF_INIT ;
9981003
999- assert (out && repo && url );
1004+ GIT_ASSERT_ARG (out );
1005+ GIT_ASSERT_ARG (repo );
1006+ GIT_ASSERT_ARG (url );
10001007
10011008 if ((error = git_buf_sanitize (out )) < 0 )
10021009 return error ;
@@ -1067,28 +1074,30 @@ static int write_mapped_var(git_repository *repo, const char *name, git_configma
10671074
10681075const char * git_submodule_branch (git_submodule * submodule )
10691076{
1070- assert (submodule );
1077+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , NULL );
10711078 return submodule -> branch ;
10721079}
10731080
10741081int git_submodule_set_branch (git_repository * repo , const char * name , const char * branch )
10751082{
1076-
1077- assert ( repo && name );
1083+ GIT_ASSERT_ARG ( repo );
1084+ GIT_ASSERT_ARG ( name );
10781085
10791086 return write_var (repo , name , "branch" , branch );
10801087}
10811088
10821089int git_submodule_set_url (git_repository * repo , const char * name , const char * url )
10831090{
1084- assert (repo && name && url );
1091+ GIT_ASSERT_ARG (repo );
1092+ GIT_ASSERT_ARG (name );
1093+ GIT_ASSERT_ARG (url );
10851094
10861095 return write_var (repo , name , "url" , url );
10871096}
10881097
10891098const git_oid * git_submodule_index_id (git_submodule * submodule )
10901099{
1091- assert (submodule );
1100+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , NULL );
10921101
10931102 if (submodule -> flags & GIT_SUBMODULE_STATUS__INDEX_OID_VALID )
10941103 return & submodule -> index_oid ;
@@ -1098,7 +1107,7 @@ const git_oid *git_submodule_index_id(git_submodule *submodule)
10981107
10991108const git_oid * git_submodule_head_id (git_submodule * submodule )
11001109{
1101- assert (submodule );
1110+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , NULL );
11021111
11031112 if (submodule -> flags & GIT_SUBMODULE_STATUS__HEAD_OID_VALID )
11041113 return & submodule -> head_oid ;
@@ -1108,7 +1117,7 @@ const git_oid *git_submodule_head_id(git_submodule *submodule)
11081117
11091118const git_oid * git_submodule_wd_id (git_submodule * submodule )
11101119{
1111- assert (submodule );
1120+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , NULL );
11121121
11131122 /* load unless we think we have a valid oid */
11141123 if (!(submodule -> flags & GIT_SUBMODULE_STATUS__WD_OID_VALID )) {
@@ -1129,42 +1138,47 @@ const git_oid *git_submodule_wd_id(git_submodule *submodule)
11291138
11301139git_submodule_ignore_t git_submodule_ignore (git_submodule * submodule )
11311140{
1132- assert (submodule );
1141+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , GIT_SUBMODULE_IGNORE_UNSPECIFIED );
1142+
11331143 return (submodule -> ignore < GIT_SUBMODULE_IGNORE_NONE ) ?
11341144 GIT_SUBMODULE_IGNORE_NONE : submodule -> ignore ;
11351145}
11361146
11371147int git_submodule_set_ignore (git_repository * repo , const char * name , git_submodule_ignore_t ignore )
11381148{
1139- assert (repo && name );
1149+ GIT_ASSERT_ARG (repo );
1150+ GIT_ASSERT_ARG (name );
11401151
11411152 return write_mapped_var (repo , name , _sm_ignore_map , ARRAY_SIZE (_sm_ignore_map ), "ignore" , ignore );
11421153}
11431154
11441155git_submodule_update_t git_submodule_update_strategy (git_submodule * submodule )
11451156{
1146- assert (submodule );
1157+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , GIT_SUBMODULE_UPDATE_NONE );
1158+
11471159 return (submodule -> update < GIT_SUBMODULE_UPDATE_CHECKOUT ) ?
11481160 GIT_SUBMODULE_UPDATE_CHECKOUT : submodule -> update ;
11491161}
11501162
11511163int git_submodule_set_update (git_repository * repo , const char * name , git_submodule_update_t update )
11521164{
1153- assert (repo && name );
1165+ GIT_ASSERT_ARG (repo );
1166+ GIT_ASSERT_ARG (name );
11541167
11551168 return write_mapped_var (repo , name , _sm_update_map , ARRAY_SIZE (_sm_update_map ), "update" , update );
11561169}
11571170
11581171git_submodule_recurse_t git_submodule_fetch_recurse_submodules (
11591172 git_submodule * submodule )
11601173{
1161- assert (submodule );
1174+ GIT_ASSERT_ARG_WITH_RETVAL (submodule , GIT_SUBMODULE_RECURSE_NO );
11621175 return submodule -> fetch_recurse ;
11631176}
11641177
11651178int git_submodule_set_fetch_recurse_submodules (git_repository * repo , const char * name , git_submodule_recurse_t recurse )
11661179{
1167- assert (repo && name );
1180+ GIT_ASSERT_ARG (repo );
1181+ GIT_ASSERT_ARG (name );
11681182
11691183 return write_mapped_var (repo , name , _sm_recurse_map , ARRAY_SIZE (_sm_recurse_map ), "fetchRecurseSubmodules" , recurse );
11701184}
@@ -1261,7 +1275,7 @@ int git_submodule_update(git_submodule *sm, int init, git_submodule_update_optio
12611275 git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT ;
12621276 git_clone_options clone_options = GIT_CLONE_OPTIONS_INIT ;
12631277
1264- assert (sm );
1278+ GIT_ASSERT_ARG (sm );
12651279
12661280 if (_update_options )
12671281 memcpy (& update_options , _update_options , sizeof (git_submodule_update_options ));
@@ -1474,7 +1488,8 @@ static int git_submodule__open(
14741488 unsigned int flags = GIT_REPOSITORY_OPEN_NO_SEARCH ;
14751489 const char * wd ;
14761490
1477- assert (sm && subrepo );
1491+ GIT_ASSERT_ARG (sm );
1492+ GIT_ASSERT_ARG (subrepo );
14781493
14791494 if (git_repository__ensure_not_bare (
14801495 sm -> repo , "open submodule repository" ) < 0 )
@@ -1610,7 +1625,7 @@ int git_submodule_reload(git_submodule *sm, int force)
16101625
16111626 GIT_UNUSED (force );
16121627
1613- assert (sm );
1628+ GIT_ASSERT_ARG (sm );
16141629
16151630 if ((error = git_submodule_name_is_valid (sm -> repo , sm -> name , 0 )) <= 0 )
16161631 /* This should come with a warning, but we've no API for that */
@@ -1727,7 +1742,9 @@ int git_submodule_status(unsigned int *status, git_repository *repo, const char
17271742 git_submodule * sm ;
17281743 int error ;
17291744
1730- assert (status && repo && name );
1745+ GIT_ASSERT_ARG (status );
1746+ GIT_ASSERT_ARG (repo );
1747+ GIT_ASSERT_ARG (name );
17311748
17321749 if ((error = git_submodule_lookup (& sm , repo , name )) < 0 )
17331750 return error ;
@@ -1740,7 +1757,8 @@ int git_submodule_status(unsigned int *status, git_repository *repo, const char
17401757
17411758int git_submodule_location (unsigned int * location , git_submodule * sm )
17421759{
1743- assert (location && sm );
1760+ GIT_ASSERT_ARG (location );
1761+ GIT_ASSERT_ARG (sm );
17441762
17451763 return git_submodule__status (
17461764 location , NULL , NULL , NULL , sm , GIT_SUBMODULE_IGNORE_ALL );
0 commit comments