@@ -570,7 +570,7 @@ static int read_remote_branches(const char *refname,
570
570
unsigned char orig_sha1 [20 ];
571
571
const char * symref ;
572
572
573
- strbuf_addf (& buf , "refs/remotes/%s" , rename -> old );
573
+ strbuf_addf (& buf , "refs/remotes/%s/ " , rename -> old );
574
574
if (!prefixcmp (refname , buf .buf )) {
575
575
item = string_list_append (rename -> remote_branches , xstrdup (refname ));
576
576
symref = resolve_ref (refname , orig_sha1 , 1 , & flag );
@@ -621,10 +621,11 @@ static int mv(int argc, const char **argv)
621
621
OPT_END ()
622
622
};
623
623
struct remote * oldremote , * newremote ;
624
- struct strbuf buf = STRBUF_INIT , buf2 = STRBUF_INIT , buf3 = STRBUF_INIT ;
624
+ struct strbuf buf = STRBUF_INIT , buf2 = STRBUF_INIT , buf3 = STRBUF_INIT ,
625
+ old_remote_context = STRBUF_INIT ;
625
626
struct string_list remote_branches = STRING_LIST_INIT_NODUP ;
626
627
struct rename_info rename ;
627
- int i ;
628
+ int i , refspec_updated = 0 ;
628
629
629
630
if (argc != 3 )
630
631
usage_with_options (builtin_remote_rename_usage , options );
@@ -659,15 +660,25 @@ static int mv(int argc, const char **argv)
659
660
strbuf_addf (& buf , "remote.%s.fetch" , rename .new );
660
661
if (git_config_set_multivar (buf .buf , NULL , NULL , 1 ))
661
662
return error ("Could not remove config section '%s'" , buf .buf );
663
+ strbuf_addf (& old_remote_context , ":refs/remotes/%s/" , rename .old );
662
664
for (i = 0 ; i < oldremote -> fetch_refspec_nr ; i ++ ) {
663
665
char * ptr ;
664
666
665
667
strbuf_reset (& buf2 );
666
668
strbuf_addstr (& buf2 , oldremote -> fetch_refspec [i ]);
667
- ptr = strstr (buf2 .buf , rename .old );
668
- if (ptr )
669
- strbuf_splice (& buf2 , ptr - buf2 .buf , strlen (rename .old ),
670
- rename .new , strlen (rename .new ));
669
+ ptr = strstr (buf2 .buf , old_remote_context .buf );
670
+ if (ptr ) {
671
+ refspec_updated = 1 ;
672
+ strbuf_splice (& buf2 ,
673
+ ptr - buf2 .buf + strlen (":refs/remotes/" ),
674
+ strlen (rename .old ), rename .new ,
675
+ strlen (rename .new ));
676
+ } else
677
+ warning ("Not updating non-default fetch respec\n"
678
+ "\t%s\n"
679
+ "\tPlease update the configuration manually if necessary." ,
680
+ buf2 .buf );
681
+
671
682
if (git_config_set_multivar (buf .buf , buf2 .buf , "^$" , 0 ))
672
683
return error ("Could not append '%s'" , buf .buf );
673
684
}
@@ -685,6 +696,9 @@ static int mv(int argc, const char **argv)
685
696
}
686
697
}
687
698
699
+ if (!refspec_updated )
700
+ return 0 ;
701
+
688
702
/*
689
703
* First remove symrefs, then rename the rest, finally create
690
704
* the new symrefs.
0 commit comments