@@ -197,8 +197,7 @@ static int add(int argc, const char **argv)
197197 die (_ ("'%s' is not a valid remote name" ), name );
198198
199199 strbuf_addf (& buf , "remote.%s.url" , name );
200- if (git_config_set (buf .buf , url ))
201- return 1 ;
200+ git_config_set_or_die (buf .buf , url );
202201
203202 if (!mirror || mirror & MIRROR_FETCH ) {
204203 strbuf_reset (& buf );
@@ -214,16 +213,14 @@ static int add(int argc, const char **argv)
214213 if (mirror & MIRROR_PUSH ) {
215214 strbuf_reset (& buf );
216215 strbuf_addf (& buf , "remote.%s.mirror" , name );
217- if (git_config_set (buf .buf , "true" ))
218- return 1 ;
216+ git_config_set_or_die (buf .buf , "true" );
219217 }
220218
221219 if (fetch_tags != TAGS_DEFAULT ) {
222220 strbuf_reset (& buf );
223221 strbuf_addf (& buf , "remote.%s.tagopt" , name );
224- if (git_config_set (buf .buf ,
225- fetch_tags == TAGS_SET ? "--tags" : "--no-tags" ))
226- return 1 ;
222+ git_config_set_or_die (buf .buf ,
223+ fetch_tags == TAGS_SET ? "--tags" : "--no-tags" );
227224 }
228225
229226 if (fetch && fetch_remote (name ))
@@ -589,25 +586,20 @@ static int migrate_file(struct remote *remote)
589586
590587 strbuf_addf (& buf , "remote.%s.url" , remote -> name );
591588 for (i = 0 ; i < remote -> url_nr ; i ++ )
592- if (git_config_set_multivar (buf .buf , remote -> url [i ], "^$" , 0 ))
593- return error (_ ("Could not append '%s' to '%s'" ),
594- remote -> url [i ], buf .buf );
589+ git_config_set_multivar_or_die (buf .buf , remote -> url [i ], "^$" , 0 );
595590 strbuf_reset (& buf );
596591 strbuf_addf (& buf , "remote.%s.push" , remote -> name );
597592 for (i = 0 ; i < remote -> push_refspec_nr ; i ++ )
598- if (git_config_set_multivar (buf .buf , remote -> push_refspec [i ], "^$" , 0 ))
599- return error (_ ("Could not append '%s' to '%s'" ),
600- remote -> push_refspec [i ], buf .buf );
593+ git_config_set_multivar_or_die (buf .buf , remote -> push_refspec [i ], "^$" , 0 );
601594 strbuf_reset (& buf );
602595 strbuf_addf (& buf , "remote.%s.fetch" , remote -> name );
603596 for (i = 0 ; i < remote -> fetch_refspec_nr ; i ++ )
604- if (git_config_set_multivar (buf .buf , remote -> fetch_refspec [i ], "^$" , 0 ))
605- return error (_ ("Could not append '%s' to '%s'" ),
606- remote -> fetch_refspec [i ], buf .buf );
597+ git_config_set_multivar_or_die (buf .buf , remote -> fetch_refspec [i ], "^$" , 0 );
607598 if (remote -> origin == REMOTE_REMOTES )
608599 unlink_or_warn (git_path ("remotes/%s" , remote -> name ));
609600 else if (remote -> origin == REMOTE_BRANCHES )
610601 unlink_or_warn (git_path ("branches/%s" , remote -> name ));
602+
611603 return 0 ;
612604}
613605
@@ -654,8 +646,7 @@ static int mv(int argc, const char **argv)
654646
655647 strbuf_reset (& buf );
656648 strbuf_addf (& buf , "remote.%s.fetch" , rename .new );
657- if (git_config_set_multivar (buf .buf , NULL , NULL , 1 ))
658- return error (_ ("Could not remove config section '%s'" ), buf .buf );
649+ git_config_set_multivar_or_die (buf .buf , NULL , NULL , 1 );
659650 strbuf_addf (& old_remote_context , ":refs/remotes/%s/" , rename .old );
660651 for (i = 0 ; i < oldremote -> fetch_refspec_nr ; i ++ ) {
661652 char * ptr ;
@@ -675,8 +666,7 @@ static int mv(int argc, const char **argv)
675666 "\tPlease update the configuration manually if necessary." ),
676667 buf2 .buf );
677668
678- if (git_config_set_multivar (buf .buf , buf2 .buf , "^$" , 0 ))
679- return error (_ ("Could not append '%s'" ), buf .buf );
669+ git_config_set_multivar_or_die (buf .buf , buf2 .buf , "^$" , 0 );
680670 }
681671
682672 read_branches ();
@@ -686,9 +676,7 @@ static int mv(int argc, const char **argv)
686676 if (info -> remote_name && !strcmp (info -> remote_name , rename .old )) {
687677 strbuf_reset (& buf );
688678 strbuf_addf (& buf , "branch.%s.remote" , item -> string );
689- if (git_config_set (buf .buf , rename .new )) {
690- return error (_ ("Could not set '%s'" ), buf .buf );
691- }
679+ git_config_set_or_die (buf .buf , rename .new );
692680 }
693681 }
694682
@@ -786,10 +774,7 @@ static int rm(int argc, const char **argv)
786774 strbuf_reset (& buf );
787775 strbuf_addf (& buf , "branch.%s.%s" ,
788776 item -> string , * k );
789- if (git_config_set (buf .buf , NULL )) {
790- strbuf_release (& buf );
791- return -1 ;
792- }
777+ git_config_set_or_die (buf .buf , NULL );
793778 }
794779 }
795780 }
0 commit comments