@@ -1617,13 +1617,13 @@ static void report_set_head(const char *remote, const char *head_name,
16171617 strbuf_release (& buf_prefix );
16181618}
16191619
1620- static int set_head (const struct ref * remote_refs , int follow_remote_head ,
1621- const char * no_warn_branch )
1620+ static int set_head (const struct ref * remote_refs , struct remote * remote )
16221621{
1623- int result = 0 , create_only , is_bare , was_detached ;
1622+ int result = 0 , create_only , baremirror , was_detached ;
16241623 struct strbuf b_head = STRBUF_INIT , b_remote_head = STRBUF_INIT ,
16251624 b_local_head = STRBUF_INIT ;
1626- const char * remote = gtransport -> remote -> name ;
1625+ int follow_remote_head = remote -> follow_remote_head ;
1626+ const char * no_warn_branch = remote -> no_warn_branch ;
16271627 char * head_name = NULL ;
16281628 struct ref * ref , * matches ;
16291629 struct ref * fetch_map = NULL , * * fetch_map_tail = & fetch_map ;
@@ -1655,17 +1655,17 @@ static int set_head(const struct ref *remote_refs, int follow_remote_head,
16551655
16561656 if (!head_name )
16571657 goto cleanup ;
1658- is_bare = is_bare_repository ();
1659- create_only = follow_remote_head == FOLLOW_REMOTE_ALWAYS ? 0 : !is_bare ;
1660- if (is_bare ) {
1658+ baremirror = is_bare_repository () && remote -> mirror ;
1659+ create_only = follow_remote_head == FOLLOW_REMOTE_ALWAYS ? 0 : !baremirror ;
1660+ if (baremirror ) {
16611661 strbuf_addstr (& b_head , "HEAD" );
16621662 strbuf_addf (& b_remote_head , "refs/heads/%s" , head_name );
16631663 } else {
1664- strbuf_addf (& b_head , "refs/remotes/%s/HEAD" , remote );
1665- strbuf_addf (& b_remote_head , "refs/remotes/%s/%s" , remote , head_name );
1664+ strbuf_addf (& b_head , "refs/remotes/%s/HEAD" , remote -> name );
1665+ strbuf_addf (& b_remote_head , "refs/remotes/%s/%s" , remote -> name , head_name );
16661666 }
16671667 /* make sure it's valid */
1668- if (!is_bare && !refs_ref_exists (refs , b_remote_head .buf )) {
1668+ if (!baremirror && !refs_ref_exists (refs , b_remote_head .buf )) {
16691669 result = 1 ;
16701670 goto cleanup ;
16711671 }
@@ -1678,7 +1678,7 @@ static int set_head(const struct ref *remote_refs, int follow_remote_head,
16781678 if (verbosity >= 0 &&
16791679 follow_remote_head == FOLLOW_REMOTE_WARN &&
16801680 (!no_warn_branch || strcmp (no_warn_branch , head_name )))
1681- report_set_head (remote , head_name , & b_local_head , was_detached );
1681+ report_set_head (remote -> name , head_name , & b_local_head , was_detached );
16821682
16831683cleanup :
16841684 free (head_name );
@@ -1924,8 +1924,7 @@ static int do_fetch(struct transport *transport,
19241924 "you need to specify exactly one branch with the --set-upstream option" ));
19251925 }
19261926 }
1927- if (set_head (remote_refs , transport -> remote -> follow_remote_head ,
1928- transport -> remote -> no_warn_branch ))
1927+ if (set_head (remote_refs , transport -> remote ))
19291928 ;
19301929 /*
19311930 * Way too many cases where this can go wrong
0 commit comments