@@ -73,7 +73,6 @@ struct display_state {
73
73
int url_len , shown_url ;
74
74
};
75
75
76
- static int fetch_show_forced_updates = 1 ;
77
76
static uint64_t forced_updates_ms = 0 ;
78
77
static int prefetch = 0 ;
79
78
static int prune = -1 ; /* unspecified */
@@ -108,6 +107,7 @@ struct fetch_config {
108
107
enum display_format display_format ;
109
108
int prune ;
110
109
int prune_tags ;
110
+ int show_forced_updates ;
111
111
};
112
112
113
113
static int git_fetch_config (const char * k , const char * v , void * cb )
@@ -125,7 +125,7 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
125
125
}
126
126
127
127
if (!strcmp (k , "fetch.showforcedupdates" )) {
128
- fetch_show_forced_updates = git_config_bool (k , v );
128
+ fetch_config -> show_forced_updates = git_config_bool (k , v );
129
129
return 0 ;
130
130
}
131
131
@@ -891,7 +891,8 @@ static int update_local_ref(struct ref *ref,
891
891
struct ref_transaction * transaction ,
892
892
struct display_state * display_state ,
893
893
const struct ref * remote_ref ,
894
- int summary_width )
894
+ int summary_width ,
895
+ const struct fetch_config * config )
895
896
{
896
897
struct commit * current = NULL , * updated ;
897
898
int fast_forward = 0 ;
@@ -972,7 +973,7 @@ static int update_local_ref(struct ref *ref,
972
973
return r ;
973
974
}
974
975
975
- if (fetch_show_forced_updates ) {
976
+ if (config -> show_forced_updates ) {
976
977
uint64_t t_before = getnanotime ();
977
978
fast_forward = repo_in_merge_bases (the_repository , current ,
978
979
updated );
@@ -1125,7 +1126,8 @@ static int store_updated_refs(struct display_state *display_state,
1125
1126
const char * remote_name ,
1126
1127
int connectivity_checked ,
1127
1128
struct ref_transaction * transaction , struct ref * ref_map ,
1128
- struct fetch_head * fetch_head )
1129
+ struct fetch_head * fetch_head ,
1130
+ const struct fetch_config * config )
1129
1131
{
1130
1132
int rc = 0 ;
1131
1133
struct strbuf note = STRBUF_INIT ;
@@ -1241,7 +1243,7 @@ static int store_updated_refs(struct display_state *display_state,
1241
1243
1242
1244
if (ref ) {
1243
1245
rc |= update_local_ref (ref , transaction , display_state ,
1244
- rm , summary_width );
1246
+ rm , summary_width , config );
1245
1247
free (ref );
1246
1248
} else if (write_fetch_head || dry_run ) {
1247
1249
/*
@@ -1265,7 +1267,7 @@ static int store_updated_refs(struct display_state *display_state,
1265
1267
"branches" ), remote_name );
1266
1268
1267
1269
if (advice_enabled (ADVICE_FETCH_SHOW_FORCED_UPDATES )) {
1268
- if (!fetch_show_forced_updates ) {
1270
+ if (!config -> show_forced_updates ) {
1269
1271
warning (_ (warn_show_forced_updates ));
1270
1272
} else if (forced_updates_ms > FORCED_UPDATES_DELAY_WARNING_IN_MS ) {
1271
1273
warning (_ (warn_time_show_forced_updates ),
@@ -1326,7 +1328,8 @@ static int fetch_and_consume_refs(struct display_state *display_state,
1326
1328
struct transport * transport ,
1327
1329
struct ref_transaction * transaction ,
1328
1330
struct ref * ref_map ,
1329
- struct fetch_head * fetch_head )
1331
+ struct fetch_head * fetch_head ,
1332
+ const struct fetch_config * config )
1330
1333
{
1331
1334
int connectivity_checked = 1 ;
1332
1335
int ret ;
@@ -1349,7 +1352,7 @@ static int fetch_and_consume_refs(struct display_state *display_state,
1349
1352
trace2_region_enter ("fetch" , "consume_refs" , the_repository );
1350
1353
ret = store_updated_refs (display_state , transport -> remote -> name ,
1351
1354
connectivity_checked , transaction , ref_map ,
1352
- fetch_head );
1355
+ fetch_head , config );
1353
1356
trace2_region_leave ("fetch" , "consume_refs" , the_repository );
1354
1357
1355
1358
out :
@@ -1520,7 +1523,8 @@ static int backfill_tags(struct display_state *display_state,
1520
1523
struct transport * transport ,
1521
1524
struct ref_transaction * transaction ,
1522
1525
struct ref * ref_map ,
1523
- struct fetch_head * fetch_head )
1526
+ struct fetch_head * fetch_head ,
1527
+ const struct fetch_config * config )
1524
1528
{
1525
1529
int retcode , cannot_reuse ;
1526
1530
@@ -1541,7 +1545,8 @@ static int backfill_tags(struct display_state *display_state,
1541
1545
transport_set_option (transport , TRANS_OPT_FOLLOWTAGS , NULL );
1542
1546
transport_set_option (transport , TRANS_OPT_DEPTH , "0" );
1543
1547
transport_set_option (transport , TRANS_OPT_DEEPEN_RELATIVE , NULL );
1544
- retcode = fetch_and_consume_refs (display_state , transport , transaction , ref_map , fetch_head );
1548
+ retcode = fetch_and_consume_refs (display_state , transport , transaction , ref_map ,
1549
+ fetch_head , config );
1545
1550
1546
1551
if (gsecondary ) {
1547
1552
transport_disconnect (gsecondary );
@@ -1668,7 +1673,8 @@ static int do_fetch(struct transport *transport,
1668
1673
retcode = 1 ;
1669
1674
}
1670
1675
1671
- if (fetch_and_consume_refs (& display_state , transport , transaction , ref_map , & fetch_head )) {
1676
+ if (fetch_and_consume_refs (& display_state , transport , transaction , ref_map ,
1677
+ & fetch_head , config )) {
1672
1678
retcode = 1 ;
1673
1679
goto cleanup ;
1674
1680
}
@@ -1691,7 +1697,7 @@ static int do_fetch(struct transport *transport,
1691
1697
* the transaction and don't commit anything.
1692
1698
*/
1693
1699
if (backfill_tags (& display_state , transport , transaction , tags_ref_map ,
1694
- & fetch_head ))
1700
+ & fetch_head , config ))
1695
1701
retcode = 1 ;
1696
1702
}
1697
1703
@@ -2110,6 +2116,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2110
2116
.display_format = DISPLAY_FORMAT_FULL ,
2111
2117
.prune = -1 ,
2112
2118
.prune_tags = -1 ,
2119
+ .show_forced_updates = 1 ,
2113
2120
};
2114
2121
const char * submodule_prefix = "" ;
2115
2122
const char * bundle_uri ;
@@ -2207,7 +2214,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2207
2214
N_ ("run 'maintenance --auto' after fetching" )),
2208
2215
OPT_BOOL (0 , "auto-gc" , & enable_auto_gc ,
2209
2216
N_ ("run 'maintenance --auto' after fetching" )),
2210
- OPT_BOOL (0 , "show-forced-updates" , & fetch_show_forced_updates ,
2217
+ OPT_BOOL (0 , "show-forced-updates" , & config . show_forced_updates ,
2211
2218
N_ ("check for forced-updates on all updated branches" )),
2212
2219
OPT_BOOL (0 , "write-commit-graph" , & fetch_write_commit_graph ,
2213
2220
N_ ("write the commit-graph after fetching" )),
0 commit comments