Skip to content

Commit 2d5c298

Browse files
iabervongitster
authored andcommitted
Mark the list of refs to fetch as const
Fetching the objects doesn't actually modify the list in any of the code paths, so this will allow code that fetches the entire (const) list of available refs to just pass the list in directly. Signed-off-by: Daniel Barkalow <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c697ad1 commit 2d5c298

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

transport.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport)
203203
}
204204

205205
static int fetch_objs_via_rsync(struct transport *transport,
206-
int nr_objs, struct ref **to_fetch)
206+
int nr_objs, const struct ref **to_fetch)
207207
{
208208
struct strbuf buf = STRBUF_INIT;
209209
struct child_process rsync;
@@ -350,7 +350,7 @@ static int rsync_transport_push(struct transport *transport,
350350

351351
#ifndef NO_CURL /* http fetch is the only user */
352352
static int fetch_objs_via_walker(struct transport *transport,
353-
int nr_objs, struct ref **to_fetch)
353+
int nr_objs, const struct ref **to_fetch)
354354
{
355355
char *dest = xstrdup(transport->url);
356356
struct walker *walker = transport->data;
@@ -504,7 +504,7 @@ static struct ref *get_refs_via_curl(struct transport *transport)
504504
}
505505

506506
static int fetch_objs_via_curl(struct transport *transport,
507-
int nr_objs, struct ref **to_fetch)
507+
int nr_objs, const struct ref **to_fetch)
508508
{
509509
if (!transport->data)
510510
transport->data = get_http_walker(transport->url,
@@ -542,7 +542,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport)
542542
}
543543

544544
static int fetch_refs_from_bundle(struct transport *transport,
545-
int nr_heads, struct ref **to_fetch)
545+
int nr_heads, const struct ref **to_fetch)
546546
{
547547
struct bundle_transport_data *data = transport->data;
548548
return unbundle(&data->header, data->fd);
@@ -616,7 +616,7 @@ static struct ref *get_refs_via_connect(struct transport *transport)
616616
}
617617

618618
static int fetch_refs_via_pack(struct transport *transport,
619-
int nr_heads, struct ref **to_fetch)
619+
int nr_heads, const struct ref **to_fetch)
620620
{
621621
struct git_transport_data *data = transport->data;
622622
char **heads = xmalloc(nr_heads * sizeof(*heads));
@@ -784,12 +784,12 @@ const struct ref *transport_get_remote_refs(struct transport *transport)
784784
return transport->remote_refs;
785785
}
786786

787-
int transport_fetch_refs(struct transport *transport, struct ref *refs)
787+
int transport_fetch_refs(struct transport *transport, const struct ref *refs)
788788
{
789789
int rc;
790790
int nr_heads = 0, nr_alloc = 0;
791-
struct ref **heads = NULL;
792-
struct ref *rm;
791+
const struct ref **heads = NULL;
792+
const struct ref *rm;
793793

794794
for (rm = refs; rm; rm = rm->next) {
795795
if (rm->peer_ref &&

transport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct transport {
1919
const char *value);
2020

2121
struct ref *(*get_refs_list)(struct transport *transport);
22-
int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs);
22+
int (*fetch)(struct transport *transport, int refs_nr, const struct ref **refs);
2323
int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags);
2424

2525
int (*disconnect)(struct transport *connection);
@@ -68,7 +68,7 @@ int transport_push(struct transport *connection,
6868

6969
const struct ref *transport_get_remote_refs(struct transport *transport);
7070

71-
int transport_fetch_refs(struct transport *transport, struct ref *refs);
71+
int transport_fetch_refs(struct transport *transport, const struct ref *refs);
7272
void transport_unlock_pack(struct transport *transport);
7373
int transport_disconnect(struct transport *transport);
7474

0 commit comments

Comments
 (0)