@@ -164,6 +164,7 @@ static int add(int argc, const char **argv, const char *prefix)
164
164
struct strbuf buf = STRBUF_INIT , buf2 = STRBUF_INIT ;
165
165
const char * name , * url ;
166
166
int i ;
167
+ int result = 0 ;
167
168
168
169
struct option options [] = {
169
170
OPT_BOOL ('f' , "fetch" , & fetch , N_ ("fetch the remote branches" )),
@@ -230,8 +231,10 @@ static int add(int argc, const char **argv, const char *prefix)
230
231
fetch_tags == TAGS_SET ? "--tags" : "--no-tags" );
231
232
}
232
233
233
- if (fetch && fetch_remote (name ))
234
- return 1 ;
234
+ if (fetch && fetch_remote (name )) {
235
+ result = 1 ;
236
+ goto out ;
237
+ }
235
238
236
239
if (master ) {
237
240
strbuf_reset (& buf );
@@ -241,14 +244,15 @@ static int add(int argc, const char **argv, const char *prefix)
241
244
strbuf_addf (& buf2 , "refs/remotes/%s/%s" , name , master );
242
245
243
246
if (refs_update_symref (get_main_ref_store (the_repository ), buf .buf , buf2 .buf , "remote add" ))
244
- return error (_ ("Could not setup master '%s'" ), master );
247
+ result = error (_ ("Could not setup master '%s'" ), master );
245
248
}
246
249
250
+ out :
247
251
strbuf_release (& buf );
248
252
strbuf_release (& buf2 );
249
253
string_list_clear (& track , 0 );
250
254
251
- return 0 ;
255
+ return result ;
252
256
}
253
257
254
258
struct branch_info {
@@ -715,6 +719,7 @@ static int mv(int argc, const char **argv, const char *prefix)
715
719
struct rename_info rename ;
716
720
int i , refs_renamed_nr = 0 , refspec_updated = 0 ;
717
721
struct progress * progress = NULL ;
722
+ int result = 0 ;
718
723
719
724
argc = parse_options (argc , argv , prefix , options ,
720
725
builtin_remote_rename_usage , 0 );
@@ -747,9 +752,11 @@ static int mv(int argc, const char **argv, const char *prefix)
747
752
748
753
strbuf_addf (& buf , "remote.%s" , rename .old_name );
749
754
strbuf_addf (& buf2 , "remote.%s" , rename .new_name );
750
- if (repo_config_rename_section (the_repository , buf .buf , buf2 .buf ) < 1 )
751
- return error (_ ("Could not rename config section '%s' to '%s'" ),
752
- buf .buf , buf2 .buf );
755
+ if (repo_config_rename_section (the_repository , buf .buf , buf2 .buf ) < 1 ) {
756
+ result = error (_ ("Could not rename config section '%s' to '%s'" ),
757
+ buf .buf , buf2 .buf );
758
+ goto out ;
759
+ }
753
760
754
761
if (oldremote -> fetch .raw_nr ) {
755
762
strbuf_reset (& buf );
@@ -870,7 +877,7 @@ static int mv(int argc, const char **argv, const char *prefix)
870
877
strbuf_release (& buf );
871
878
strbuf_release (& buf2 );
872
879
strbuf_release (& buf3 );
873
- return 0 ;
880
+ return result ;
874
881
}
875
882
876
883
static int rm (int argc , const char * * argv , const char * prefix )
0 commit comments