726
return error(_("Could not rename config section '%s' to '%s'"),
727
buf.buf, buf2.buf);
728
729
- strbuf_reset(&buf);
730
- strbuf_addf(&buf, "remote.%s.fetch", rename.new_name);
731
- git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
732
- strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old_name);
733
- for (i = 0; i < oldremote->fetch.raw_nr; i++) {
734
- char *ptr;
735
-
736
- strbuf_reset(&buf2);
737
- strbuf_addstr(&buf2, oldremote->fetch.raw[i]);
738
- ptr = strstr(buf2.buf, old_remote_context.buf);
739
- if (ptr) {
740
- refspec_updated = 1;
741
- strbuf_splice(&buf2,
742
- ptr-buf2.buf + strlen(":refs/remotes/"),
743
- strlen(rename.old_name), rename.new_name,
744
- strlen(rename.new_name));
745
- } else
746
- warning(_("Not updating non-default fetch refspec\n"
747
- "\t%s\n"
748
- "\tPlease update the configuration manually if necessary."),
749
- buf2.buf);
750
-
751
- git_config_set_multivar(buf.buf, buf2.buf, "^$", 0);
729
+ if (oldremote->fetch.raw_nr) {
730
+ strbuf_reset(&buf);
731
+ strbuf_addf(&buf, "remote.%s.fetch", rename.new_name);
732
+ git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
733
+ strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old_name);
734
+ for (i = 0; i < oldremote->fetch.raw_nr; i++) {
735
+ char *ptr;
736
+
737
+ strbuf_reset(&buf2);
738
+ strbuf_addstr(&buf2, oldremote->fetch.raw[i]);
739
+ ptr = strstr(buf2.buf, old_remote_context.buf);
740
+ if (ptr) {
741
+ refspec_updated = 1;
742
+ strbuf_splice(&buf2,
743
+ ptr-buf2.buf + strlen(":refs/remotes/"),
744
+ strlen(rename.old_name), rename.new_name,
745
+ strlen(rename.new_name));
746
+ } else
747
+ warning(_("Not updating non-default fetch refspec\n"
748
+ "\t%s\n"
749
+ "\tPlease update the configuration manually if necessary."),
750
+ buf2.buf);
751
+
752
+ git_config_set_multivar(buf.buf, buf2.buf, "^$", 0);
753
+ }
754
}
755
756
read_branches();