fetch: stop passing around unused worktrees variable
In 12d47e3b1f (fetch: use new branch_checked_out() and add tests, 2022-06-14), fetch's update_local_ref() function stopped using its "worktrees" parameter. It doesn't need it, since the branch_checked_out() function examines the global worktrees under the hood. So we can not only drop the unused parameter from that function, but also from its entire call chain. And as we do so all the way up to do_fetch(), we can see that nobody uses it at all, and we can drop the local variable there entirely. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 18, 2022 at 23:53 UTC
b2463fc30a43a43b5de788fa1611603f84097873
1 file changed
+9
-15
builtin/fetch.c
+9
-15
@@ -881,8 +881,7 @@ static void format_display(struct strbuf *display, char code,
881
static int update_local_ref(struct ref *ref,
882
struct ref_transaction *transaction,
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)
885
{
886
struct commit *current = NULL, *updated;
887
const char *pretty_ref = prettify_refname(ref->name);
@@ -1107,7 +1106,7 @@ N_("it took %.2f seconds to check forced updates; you can use\n"
1106
static int store_updated_refs(const char *raw_url, const char *remote_name,
1107
int connectivity_checked,
1108
struct ref_transaction *transaction, struct ref *ref_map,
1110
- struct fetch_head *fetch_head, struct worktree **worktrees)
1109
+ struct fetch_head *fetch_head)
1110
{
1111
int url_len, i, rc = 0;
1112
struct strbuf note = STRBUF_INIT, err = STRBUF_INIT;
@@ -1237,8 +1236,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
1236
strbuf_reset(¬e);
1237
if (ref) {
1238
rc |= update_local_ref(ref, transaction, what,
1240
- rm, ¬e, summary_width,
1241
- worktrees);
1239
+ rm, ¬e, summary_width);
1240
free(ref);
1241
} else if (write_fetch_head || dry_run) {
1242
/*
@@ -1329,8 +1327,7 @@ static int check_exist_and_connected(struct ref *ref_map)
1327
static int fetch_and_consume_refs(struct transport *transport,
1328
struct ref_transaction *transaction,
1329
struct ref *ref_map,
1332
- struct fetch_head *fetch_head,
1333
- struct worktree **worktrees)
1330
+ struct fetch_head *fetch_head)
1331
{
1332
int connectivity_checked = 1;
1333
int ret;
@@ -1353,7 +1350,7 @@ static int fetch_and_consume_refs(struct transport *transport,
1350
trace2_region_enter("fetch", "consume_refs", the_repository);
1351
ret = store_updated_refs(transport->url, transport->remote->name,
1352
connectivity_checked, transaction, ref_map,
1356
- fetch_head, worktrees);
1353
+ fetch_head);
1354
trace2_region_leave("fetch", "consume_refs", the_repository);
1355
1356
out:
@@ -1543,8 +1540,7 @@ static struct transport *prepare_transport(struct remote *remote, int deepen)
1540
static int backfill_tags(struct transport *transport,
1541
struct ref_transaction *transaction,
1542
struct ref *ref_map,
1546
- struct fetch_head *fetch_head,
1547
- struct worktree **worktrees)
1543
+ struct fetch_head *fetch_head)
1544
{
1545
int retcode, cannot_reuse;
1546
@@ -1565,7 +1561,7 @@ static int backfill_tags(struct transport *transport,
1561
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
1562
transport_set_option(transport, TRANS_OPT_DEPTH, "0");
1563
transport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL);
1568
- retcode = fetch_and_consume_refs(transport, transaction, ref_map, fetch_head, worktrees);
1564
+ retcode = fetch_and_consume_refs(transport, transaction, ref_map, fetch_head);
1565
1566
if (gsecondary) {
1567
transport_disconnect(gsecondary);
@@ -1586,7 +1582,6 @@ static int do_fetch(struct transport *transport,
1582
struct transport_ls_refs_options transport_ls_refs_options =
1583
TRANSPORT_LS_REFS_OPTIONS_INIT;
1584
int must_list_refs = 1;
1589
- struct worktree **worktrees = get_worktrees();
1585
struct fetch_head fetch_head = { 0 };
1586
struct strbuf err = STRBUF_INIT;
1587
@@ -1677,7 +1672,7 @@ static int do_fetch(struct transport *transport,
1672
retcode = 1;
1673
}
1674
1680
- if (fetch_and_consume_refs(transport, transaction, ref_map, &fetch_head, worktrees)) {
1675
+ if (fetch_and_consume_refs(transport, transaction, ref_map, &fetch_head)) {
1676
retcode = 1;
1677
goto cleanup;
1678
}
@@ -1700,7 +1695,7 @@ static int do_fetch(struct transport *transport,
1695
* the transaction and don't commit anything.
1696
*/
1697
if (backfill_tags(transport, transaction, tags_ref_map,
1703
- &fetch_head, worktrees))
1698
+ &fetch_head))
1699
retcode = 1;
1700
}
1701
@@ -1785,7 +1780,6 @@ cleanup:
1780
close_fetch_head(&fetch_head);
1781
strbuf_release(&err);
1782
free_refs(ref_map);
1788
- free_worktrees(worktrees);
1783
return retcode;
1784
}
1785