Skip to content

Commit b2463fc

Browse files
peffgitster
authored andcommitted
fetch: stop passing around unused worktrees variable
In 12d47e3 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4b6e18f commit b2463fc

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

builtin/fetch.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,7 @@ static void format_display(struct strbuf *display, char code,
881881
static int update_local_ref(struct ref *ref,
882882
struct ref_transaction *transaction,
883883
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)
886885
{
887886
struct commit *current = NULL, *updated;
888887
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"
11071106
static int store_updated_refs(const char *raw_url, const char *remote_name,
11081107
int connectivity_checked,
11091108
struct ref_transaction *transaction, struct ref *ref_map,
1110-
struct fetch_head *fetch_head, struct worktree **worktrees)
1109+
struct fetch_head *fetch_head)
11111110
{
11121111
int url_len, i, rc = 0;
11131112
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,
12371236
strbuf_reset(&note);
12381237
if (ref) {
12391238
rc |= update_local_ref(ref, transaction, what,
1240-
rm, &note, summary_width,
1241-
worktrees);
1239+
rm, &note, summary_width);
12421240
free(ref);
12431241
} else if (write_fetch_head || dry_run) {
12441242
/*
@@ -1329,8 +1327,7 @@ static int check_exist_and_connected(struct ref *ref_map)
13291327
static int fetch_and_consume_refs(struct transport *transport,
13301328
struct ref_transaction *transaction,
13311329
struct ref *ref_map,
1332-
struct fetch_head *fetch_head,
1333-
struct worktree **worktrees)
1330+
struct fetch_head *fetch_head)
13341331
{
13351332
int connectivity_checked = 1;
13361333
int ret;
@@ -1353,7 +1350,7 @@ static int fetch_and_consume_refs(struct transport *transport,
13531350
trace2_region_enter("fetch", "consume_refs", the_repository);
13541351
ret = store_updated_refs(transport->url, transport->remote->name,
13551352
connectivity_checked, transaction, ref_map,
1356-
fetch_head, worktrees);
1353+
fetch_head);
13571354
trace2_region_leave("fetch", "consume_refs", the_repository);
13581355

13591356
out:
@@ -1543,8 +1540,7 @@ static struct transport *prepare_transport(struct remote *remote, int deepen)
15431540
static int backfill_tags(struct transport *transport,
15441541
struct ref_transaction *transaction,
15451542
struct ref *ref_map,
1546-
struct fetch_head *fetch_head,
1547-
struct worktree **worktrees)
1543+
struct fetch_head *fetch_head)
15481544
{
15491545
int retcode, cannot_reuse;
15501546

@@ -1565,7 +1561,7 @@ static int backfill_tags(struct transport *transport,
15651561
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
15661562
transport_set_option(transport, TRANS_OPT_DEPTH, "0");
15671563
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);
15691565

15701566
if (gsecondary) {
15711567
transport_disconnect(gsecondary);
@@ -1586,7 +1582,6 @@ static int do_fetch(struct transport *transport,
15861582
struct transport_ls_refs_options transport_ls_refs_options =
15871583
TRANSPORT_LS_REFS_OPTIONS_INIT;
15881584
int must_list_refs = 1;
1589-
struct worktree **worktrees = get_worktrees();
15901585
struct fetch_head fetch_head = { 0 };
15911586
struct strbuf err = STRBUF_INIT;
15921587

@@ -1677,7 +1672,7 @@ static int do_fetch(struct transport *transport,
16771672
retcode = 1;
16781673
}
16791674

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)) {
16811676
retcode = 1;
16821677
goto cleanup;
16831678
}
@@ -1700,7 +1695,7 @@ static int do_fetch(struct transport *transport,
17001695
* the transaction and don't commit anything.
17011696
*/
17021697
if (backfill_tags(transport, transaction, tags_ref_map,
1703-
&fetch_head, worktrees))
1698+
&fetch_head))
17041699
retcode = 1;
17051700
}
17061701

@@ -1785,7 +1780,6 @@ static int do_fetch(struct transport *transport,
17851780
close_fetch_head(&fetch_head);
17861781
strbuf_release(&err);
17871782
free_refs(ref_map);
1788-
free_worktrees(worktrees);
17891783
return retcode;
17901784
}
17911785

0 commit comments

Comments
 (0)