@@ -197,8 +197,7 @@ static int add(int argc, const char **argv)
197
197
die (_ ("'%s' is not a valid remote name" ), name );
198
198
199
199
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 );
202
201
203
202
if (!mirror || mirror & MIRROR_FETCH ) {
204
203
strbuf_reset (& buf );
@@ -214,16 +213,14 @@ static int add(int argc, const char **argv)
214
213
if (mirror & MIRROR_PUSH ) {
215
214
strbuf_reset (& buf );
216
215
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" );
219
217
}
220
218
221
219
if (fetch_tags != TAGS_DEFAULT ) {
222
220
strbuf_reset (& buf );
223
221
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" );
227
224
}
228
225
229
226
if (fetch && fetch_remote (name ))
@@ -589,25 +586,20 @@ static int migrate_file(struct remote *remote)
589
586
590
587
strbuf_addf (& buf , "remote.%s.url" , remote -> name );
591
588
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 );
595
590
strbuf_reset (& buf );
596
591
strbuf_addf (& buf , "remote.%s.push" , remote -> name );
597
592
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 );
601
594
strbuf_reset (& buf );
602
595
strbuf_addf (& buf , "remote.%s.fetch" , remote -> name );
603
596
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 );
607
598
if (remote -> origin == REMOTE_REMOTES )
608
599
unlink_or_warn (git_path ("remotes/%s" , remote -> name ));
609
600
else if (remote -> origin == REMOTE_BRANCHES )
610
601
unlink_or_warn (git_path ("branches/%s" , remote -> name ));
602
+
611
603
return 0 ;
612
604
}
613
605
@@ -654,8 +646,7 @@ static int mv(int argc, const char **argv)
654
646
655
647
strbuf_reset (& buf );
656
648
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 );
659
650
strbuf_addf (& old_remote_context , ":refs/remotes/%s/" , rename .old );
660
651
for (i = 0 ; i < oldremote -> fetch_refspec_nr ; i ++ ) {
661
652
char * ptr ;
@@ -675,8 +666,7 @@ static int mv(int argc, const char **argv)
675
666
"\tPlease update the configuration manually if necessary." ),
676
667
buf2 .buf );
677
668
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 );
680
670
}
681
671
682
672
read_branches ();
@@ -686,9 +676,7 @@ static int mv(int argc, const char **argv)
686
676
if (info -> remote_name && !strcmp (info -> remote_name , rename .old )) {
687
677
strbuf_reset (& buf );
688
678
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 );
692
680
}
693
681
}
694
682
@@ -786,10 +774,7 @@ static int rm(int argc, const char **argv)
786
774
strbuf_reset (& buf );
787
775
strbuf_addf (& buf , "branch.%s.%s" ,
788
776
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 );
793
778
}
794
779
}
795
780
}
0 commit comments