@@ -881,11 +881,9 @@ static void format_display(struct strbuf *display, char code,
881
881
static int update_local_ref (struct ref * ref ,
882
882
struct ref_transaction * transaction ,
883
883
const char * remote , const struct ref * remote_ref ,
884
- struct strbuf * display , int summary_width ,
885
- struct worktree * * worktrees )
884
+ struct strbuf * display , int summary_width )
886
885
{
887
886
struct commit * current = NULL , * updated ;
888
- const struct worktree * wt ;
889
887
const char * pretty_ref = prettify_refname (ref -> name );
890
888
int fast_forward = 0 ;
891
889
@@ -900,16 +898,14 @@ static int update_local_ref(struct ref *ref,
900
898
}
901
899
902
900
if (!update_head_ok &&
903
- ( wt = find_shared_symref ( worktrees , "HEAD" , ref -> name ) ) &&
904
- ! wt -> is_bare && ! is_null_oid ( & ref -> old_oid )) {
901
+ ! is_null_oid ( & ref -> old_oid ) &&
902
+ branch_checked_out ( ref -> name )) {
905
903
/*
906
904
* If this is the head, and it's not okay to update
907
905
* the head, and the old value of the head isn't empty...
908
906
*/
909
907
format_display (display , '!' , _ ("[rejected]" ),
910
- wt -> is_current ?
911
- _ ("can't fetch in current branch" ) :
912
- _ ("checked out in another worktree" ),
908
+ _ ("can't fetch into checked-out branch" ),
913
909
remote , pretty_ref , summary_width );
914
910
return 1 ;
915
911
}
@@ -1110,7 +1106,7 @@ N_("it took %.2f seconds to check forced updates; you can use\n"
1110
1106
static int store_updated_refs (const char * raw_url , const char * remote_name ,
1111
1107
int connectivity_checked ,
1112
1108
struct ref_transaction * transaction , struct ref * ref_map ,
1113
- struct fetch_head * fetch_head , struct worktree * * worktrees )
1109
+ struct fetch_head * fetch_head )
1114
1110
{
1115
1111
int url_len , i , rc = 0 ;
1116
1112
struct strbuf note = STRBUF_INIT , err = STRBUF_INIT ;
@@ -1240,8 +1236,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
1240
1236
strbuf_reset (& note );
1241
1237
if (ref ) {
1242
1238
rc |= update_local_ref (ref , transaction , what ,
1243
- rm , & note , summary_width ,
1244
- worktrees );
1239
+ rm , & note , summary_width );
1245
1240
free (ref );
1246
1241
} else if (write_fetch_head || dry_run ) {
1247
1242
/*
@@ -1332,8 +1327,7 @@ static int check_exist_and_connected(struct ref *ref_map)
1332
1327
static int fetch_and_consume_refs (struct transport * transport ,
1333
1328
struct ref_transaction * transaction ,
1334
1329
struct ref * ref_map ,
1335
- struct fetch_head * fetch_head ,
1336
- struct worktree * * worktrees )
1330
+ struct fetch_head * fetch_head )
1337
1331
{
1338
1332
int connectivity_checked = 1 ;
1339
1333
int ret ;
@@ -1356,7 +1350,7 @@ static int fetch_and_consume_refs(struct transport *transport,
1356
1350
trace2_region_enter ("fetch" , "consume_refs" , the_repository );
1357
1351
ret = store_updated_refs (transport -> url , transport -> remote -> name ,
1358
1352
connectivity_checked , transaction , ref_map ,
1359
- fetch_head , worktrees );
1353
+ fetch_head );
1360
1354
trace2_region_leave ("fetch" , "consume_refs" , the_repository );
1361
1355
1362
1356
out :
@@ -1434,19 +1428,16 @@ static int prune_refs(struct refspec *rs,
1434
1428
return result ;
1435
1429
}
1436
1430
1437
- static void check_not_current_branch (struct ref * ref_map ,
1438
- struct worktree * * worktrees )
1431
+ static void check_not_current_branch (struct ref * ref_map )
1439
1432
{
1440
- const struct worktree * wt ;
1433
+ const char * path ;
1441
1434
for (; ref_map ; ref_map = ref_map -> next )
1442
1435
if (ref_map -> peer_ref &&
1443
1436
starts_with (ref_map -> peer_ref -> name , "refs/heads/" ) &&
1444
- (wt = find_shared_symref (worktrees , "HEAD" ,
1445
- ref_map -> peer_ref -> name )) &&
1446
- !wt -> is_bare )
1437
+ (path = branch_checked_out (ref_map -> peer_ref -> name )))
1447
1438
die (_ ("refusing to fetch into branch '%s' "
1448
1439
"checked out at '%s'" ),
1449
- ref_map -> peer_ref -> name , wt -> path );
1440
+ ref_map -> peer_ref -> name , path );
1450
1441
}
1451
1442
1452
1443
static int truncate_fetch_head (void )
@@ -1549,8 +1540,7 @@ static struct transport *prepare_transport(struct remote *remote, int deepen)
1549
1540
static int backfill_tags (struct transport * transport ,
1550
1541
struct ref_transaction * transaction ,
1551
1542
struct ref * ref_map ,
1552
- struct fetch_head * fetch_head ,
1553
- struct worktree * * worktrees )
1543
+ struct fetch_head * fetch_head )
1554
1544
{
1555
1545
int retcode , cannot_reuse ;
1556
1546
@@ -1571,7 +1561,7 @@ static int backfill_tags(struct transport *transport,
1571
1561
transport_set_option (transport , TRANS_OPT_FOLLOWTAGS , NULL );
1572
1562
transport_set_option (transport , TRANS_OPT_DEPTH , "0" );
1573
1563
transport_set_option (transport , TRANS_OPT_DEEPEN_RELATIVE , NULL );
1574
- retcode = fetch_and_consume_refs (transport , transaction , ref_map , fetch_head , worktrees );
1564
+ retcode = fetch_and_consume_refs (transport , transaction , ref_map , fetch_head );
1575
1565
1576
1566
if (gsecondary ) {
1577
1567
transport_disconnect (gsecondary );
@@ -1592,7 +1582,6 @@ static int do_fetch(struct transport *transport,
1592
1582
struct transport_ls_refs_options transport_ls_refs_options =
1593
1583
TRANSPORT_LS_REFS_OPTIONS_INIT ;
1594
1584
int must_list_refs = 1 ;
1595
- struct worktree * * worktrees = get_worktrees ();
1596
1585
struct fetch_head fetch_head = { 0 };
1597
1586
struct strbuf err = STRBUF_INIT ;
1598
1587
@@ -1650,7 +1639,7 @@ static int do_fetch(struct transport *transport,
1650
1639
ref_map = get_ref_map (transport -> remote , remote_refs , rs ,
1651
1640
tags , & autotags );
1652
1641
if (!update_head_ok )
1653
- check_not_current_branch (ref_map , worktrees );
1642
+ check_not_current_branch (ref_map );
1654
1643
1655
1644
retcode = open_fetch_head (& fetch_head );
1656
1645
if (retcode )
@@ -1683,7 +1672,7 @@ static int do_fetch(struct transport *transport,
1683
1672
retcode = 1 ;
1684
1673
}
1685
1674
1686
- if (fetch_and_consume_refs (transport , transaction , ref_map , & fetch_head , worktrees )) {
1675
+ if (fetch_and_consume_refs (transport , transaction , ref_map , & fetch_head )) {
1687
1676
retcode = 1 ;
1688
1677
goto cleanup ;
1689
1678
}
@@ -1706,7 +1695,7 @@ static int do_fetch(struct transport *transport,
1706
1695
* the transaction and don't commit anything.
1707
1696
*/
1708
1697
if (backfill_tags (transport , transaction , tags_ref_map ,
1709
- & fetch_head , worktrees ))
1698
+ & fetch_head ))
1710
1699
retcode = 1 ;
1711
1700
}
1712
1701
@@ -1791,7 +1780,6 @@ static int do_fetch(struct transport *transport,
1791
1780
close_fetch_head (& fetch_head );
1792
1781
strbuf_release (& err );
1793
1782
free_refs (ref_map );
1794
- free_worktrees (worktrees );
1795
1783
return retcode ;
1796
1784
}
1797
1785
0 commit comments