@@ -486,6 +486,29 @@ static void write_followtags(const struct ref *refs, const char *msg)
486
486
}
487
487
}
488
488
489
+ static void update_remote_refs (const struct ref * refs ,
490
+ const struct ref * mapped_refs ,
491
+ const struct ref * remote_head_points_at ,
492
+ const char * branch_top ,
493
+ const char * msg )
494
+ {
495
+ if (refs ) {
496
+ clear_extra_refs ();
497
+ write_remote_refs (mapped_refs );
498
+ if (option_single_branch )
499
+ write_followtags (refs , msg );
500
+ }
501
+
502
+ if (remote_head_points_at && !option_bare ) {
503
+ struct strbuf head_ref = STRBUF_INIT ;
504
+ strbuf_addstr (& head_ref , branch_top );
505
+ strbuf_addstr (& head_ref , "HEAD" );
506
+ create_symref (head_ref .buf ,
507
+ remote_head_points_at -> peer_ref -> name ,
508
+ msg );
509
+ }
510
+ }
511
+
489
512
static void update_head (const struct ref * our , const struct ref * remote ,
490
513
const char * msg )
491
514
{
@@ -782,12 +805,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
782
805
}
783
806
784
807
if (refs ) {
785
- clear_extra_refs ();
786
-
787
- write_remote_refs (mapped_refs );
788
- if (option_single_branch )
789
- write_followtags (refs , reflog_msg .buf );
790
-
791
808
remote_head = find_ref_by_name (refs , "HEAD" );
792
809
remote_head_points_at =
793
810
guess_remote_head (remote_head , mapped_refs , 0 );
@@ -821,14 +838,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
821
838
"refs/heads/master" );
822
839
}
823
840
824
- if (remote_head_points_at && !option_bare ) {
825
- struct strbuf head_ref = STRBUF_INIT ;
826
- strbuf_addstr (& head_ref , branch_top .buf );
827
- strbuf_addstr (& head_ref , "HEAD" );
828
- create_symref (head_ref .buf ,
829
- remote_head_points_at -> peer_ref -> name ,
830
- reflog_msg .buf );
831
- }
841
+ update_remote_refs (refs , mapped_refs , remote_head_points_at ,
842
+ branch_top .buf , reflog_msg .buf );
832
843
833
844
update_head (our_head_points_at , remote_head , reflog_msg .buf );
834
845
0 commit comments