@@ -580,7 +580,7 @@ static int read_remote_branches(const char *refname,
580
580
unsigned char orig_sha1 [20 ];
581
581
const char * symref ;
582
582
583
- strbuf_addf (& buf , "refs/remotes/%s" , rename -> old );
583
+ strbuf_addf (& buf , "refs/remotes/%s/ " , rename -> old );
584
584
if (!prefixcmp (refname , buf .buf )) {
585
585
item = string_list_append (rename -> remote_branches , xstrdup (refname ));
586
586
symref = resolve_ref (refname , orig_sha1 , 1 , & flag );
@@ -631,10 +631,11 @@ static int mv(int argc, const char **argv)
631
631
OPT_END ()
632
632
};
633
633
struct remote * oldremote , * newremote ;
634
- struct strbuf buf = STRBUF_INIT , buf2 = STRBUF_INIT , buf3 = STRBUF_INIT ;
634
+ struct strbuf buf = STRBUF_INIT , buf2 = STRBUF_INIT , buf3 = STRBUF_INIT ,
635
+ old_remote_context = STRBUF_INIT ;
635
636
struct string_list remote_branches = STRING_LIST_INIT_NODUP ;
636
637
struct rename_info rename ;
637
- int i ;
638
+ int i , refspec_updated = 0 ;
638
639
639
640
if (argc != 3 )
640
641
usage_with_options (builtin_remote_rename_usage , options );
@@ -669,15 +670,25 @@ static int mv(int argc, const char **argv)
669
670
strbuf_addf (& buf , "remote.%s.fetch" , rename .new );
670
671
if (git_config_set_multivar (buf .buf , NULL , NULL , 1 ))
671
672
return error ("Could not remove config section '%s'" , buf .buf );
673
+ strbuf_addf (& old_remote_context , ":refs/remotes/%s/" , rename .old );
672
674
for (i = 0 ; i < oldremote -> fetch_refspec_nr ; i ++ ) {
673
675
char * ptr ;
674
676
675
677
strbuf_reset (& buf2 );
676
678
strbuf_addstr (& buf2 , oldremote -> fetch_refspec [i ]);
677
- ptr = strstr (buf2 .buf , rename .old );
678
- if (ptr )
679
- strbuf_splice (& buf2 , ptr - buf2 .buf , strlen (rename .old ),
680
- rename .new , strlen (rename .new ));
679
+ ptr = strstr (buf2 .buf , old_remote_context .buf );
680
+ if (ptr ) {
681
+ refspec_updated = 1 ;
682
+ strbuf_splice (& buf2 ,
683
+ ptr - buf2 .buf + strlen (":refs/remotes/" ),
684
+ strlen (rename .old ), rename .new ,
685
+ strlen (rename .new ));
686
+ } else
687
+ warning ("Not updating non-default fetch respec\n"
688
+ "\t%s\n"
689
+ "\tPlease update the configuration manually if necessary." ,
690
+ buf2 .buf );
691
+
681
692
if (git_config_set_multivar (buf .buf , buf2 .buf , "^$" , 0 ))
682
693
return error ("Could not append '%s'" , buf .buf );
683
694
}
@@ -695,6 +706,9 @@ static int mv(int argc, const char **argv)
695
706
}
696
707
}
697
708
709
+ if (!refspec_updated )
710
+ return 0 ;
711
+
698
712
/*
699
713
* First remove symrefs, then rename the rest, finally create
700
714
* the new symrefs.
0 commit comments