@@ -733,29 +733,31 @@ static int mv(int argc, const char **argv, const char *prefix)
733
733
return error (_ ("Could not rename config section '%s' to '%s'" ),
734
734
buf .buf , buf2 .buf );
735
735
736
- strbuf_reset (& buf );
737
- strbuf_addf (& buf , "remote.%s.fetch" , rename .new_name );
738
- git_config_set_multivar (buf .buf , NULL , NULL , CONFIG_FLAGS_MULTI_REPLACE );
739
- strbuf_addf (& old_remote_context , ":refs/remotes/%s/" , rename .old_name );
740
- for (i = 0 ; i < oldremote -> fetch .raw_nr ; i ++ ) {
741
- char * ptr ;
742
-
743
- strbuf_reset (& buf2 );
744
- strbuf_addstr (& buf2 , oldremote -> fetch .raw [i ]);
745
- ptr = strstr (buf2 .buf , old_remote_context .buf );
746
- if (ptr ) {
747
- refspec_updated = 1 ;
748
- strbuf_splice (& buf2 ,
749
- ptr - buf2 .buf + strlen (":refs/remotes/" ),
750
- strlen (rename .old_name ), rename .new_name ,
751
- strlen (rename .new_name ));
752
- } else
753
- warning (_ ("Not updating non-default fetch refspec\n"
754
- "\t%s\n"
755
- "\tPlease update the configuration manually if necessary." ),
756
- buf2 .buf );
757
-
758
- git_config_set_multivar (buf .buf , buf2 .buf , "^$" , 0 );
736
+ if (oldremote -> fetch .raw_nr ) {
737
+ strbuf_reset (& buf );
738
+ strbuf_addf (& buf , "remote.%s.fetch" , rename .new_name );
739
+ git_config_set_multivar (buf .buf , NULL , NULL , CONFIG_FLAGS_MULTI_REPLACE );
740
+ strbuf_addf (& old_remote_context , ":refs/remotes/%s/" , rename .old_name );
741
+ for (i = 0 ; i < oldremote -> fetch .raw_nr ; i ++ ) {
742
+ char * ptr ;
743
+
744
+ strbuf_reset (& buf2 );
745
+ strbuf_addstr (& buf2 , oldremote -> fetch .raw [i ]);
746
+ ptr = strstr (buf2 .buf , old_remote_context .buf );
747
+ if (ptr ) {
748
+ refspec_updated = 1 ;
749
+ strbuf_splice (& buf2 ,
750
+ ptr - buf2 .buf + strlen (":refs/remotes/" ),
751
+ strlen (rename .old_name ), rename .new_name ,
752
+ strlen (rename .new_name ));
753
+ } else
754
+ warning (_ ("Not updating non-default fetch refspec\n"
755
+ "\t%s\n"
756
+ "\tPlease update the configuration manually if necessary." ),
757
+ buf2 .buf );
758
+
759
+ git_config_set_multivar (buf .buf , buf2 .buf , "^$" , 0 );
760
+ }
759
761
}
760
762
761
763
read_branches ();
0 commit comments