@@ -1617,13 +1617,13 @@ static void report_set_head(const char *remote, const char *head_name,
1617
1617
strbuf_release (& buf_prefix );
1618
1618
}
1619
1619
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 )
1622
1621
{
1623
- int result = 0 , create_only , is_bare , was_detached ;
1622
+ int result = 0 , create_only , baremirror , was_detached ;
1624
1623
struct strbuf b_head = STRBUF_INIT , b_remote_head = STRBUF_INIT ,
1625
1624
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 ;
1627
1627
char * head_name = NULL ;
1628
1628
struct ref * ref , * matches ;
1629
1629
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,
1655
1655
1656
1656
if (!head_name )
1657
1657
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 ) {
1661
1661
strbuf_addstr (& b_head , "HEAD" );
1662
1662
strbuf_addf (& b_remote_head , "refs/heads/%s" , head_name );
1663
1663
} 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 );
1666
1666
}
1667
1667
/* 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 )) {
1669
1669
result = 1 ;
1670
1670
goto cleanup ;
1671
1671
}
@@ -1678,7 +1678,7 @@ static int set_head(const struct ref *remote_refs, int follow_remote_head,
1678
1678
if (verbosity >= 0 &&
1679
1679
follow_remote_head == FOLLOW_REMOTE_WARN &&
1680
1680
(!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 );
1682
1682
1683
1683
cleanup :
1684
1684
free (head_name );
@@ -1924,8 +1924,7 @@ static int do_fetch(struct transport *transport,
1924
1924
"you need to specify exactly one branch with the --set-upstream option" ));
1925
1925
}
1926
1926
}
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 ))
1929
1928
;
1930
1929
/*
1931
1930
* Way too many cases where this can go wrong
0 commit comments