提交 2d5c298f 编写于 作者: D Daniel Barkalow 提交者: Junio C Hamano

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: NDaniel Barkalow <barkalow@iabervon.org>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 c697ad14
...@@ -203,7 +203,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport) ...@@ -203,7 +203,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport)
} }
static int fetch_objs_via_rsync(struct transport *transport, static int fetch_objs_via_rsync(struct transport *transport,
int nr_objs, struct ref **to_fetch) int nr_objs, const struct ref **to_fetch)
{ {
struct strbuf buf = STRBUF_INIT; struct strbuf buf = STRBUF_INIT;
struct child_process rsync; struct child_process rsync;
...@@ -350,7 +350,7 @@ static int rsync_transport_push(struct transport *transport, ...@@ -350,7 +350,7 @@ static int rsync_transport_push(struct transport *transport,
#ifndef NO_CURL /* http fetch is the only user */ #ifndef NO_CURL /* http fetch is the only user */
static int fetch_objs_via_walker(struct transport *transport, static int fetch_objs_via_walker(struct transport *transport,
int nr_objs, struct ref **to_fetch) int nr_objs, const struct ref **to_fetch)
{ {
char *dest = xstrdup(transport->url); char *dest = xstrdup(transport->url);
struct walker *walker = transport->data; struct walker *walker = transport->data;
...@@ -504,7 +504,7 @@ static struct ref *get_refs_via_curl(struct transport *transport) ...@@ -504,7 +504,7 @@ static struct ref *get_refs_via_curl(struct transport *transport)
} }
static int fetch_objs_via_curl(struct transport *transport, static int fetch_objs_via_curl(struct transport *transport,
int nr_objs, struct ref **to_fetch) int nr_objs, const struct ref **to_fetch)
{ {
if (!transport->data) if (!transport->data)
transport->data = get_http_walker(transport->url, transport->data = get_http_walker(transport->url,
...@@ -542,7 +542,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport) ...@@ -542,7 +542,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport)
} }
static int fetch_refs_from_bundle(struct transport *transport, static int fetch_refs_from_bundle(struct transport *transport,
int nr_heads, struct ref **to_fetch) int nr_heads, const struct ref **to_fetch)
{ {
struct bundle_transport_data *data = transport->data; struct bundle_transport_data *data = transport->data;
return unbundle(&data->header, data->fd); return unbundle(&data->header, data->fd);
...@@ -616,7 +616,7 @@ static struct ref *get_refs_via_connect(struct transport *transport) ...@@ -616,7 +616,7 @@ static struct ref *get_refs_via_connect(struct transport *transport)
} }
static int fetch_refs_via_pack(struct transport *transport, static int fetch_refs_via_pack(struct transport *transport,
int nr_heads, struct ref **to_fetch) int nr_heads, const struct ref **to_fetch)
{ {
struct git_transport_data *data = transport->data; struct git_transport_data *data = transport->data;
char **heads = xmalloc(nr_heads * sizeof(*heads)); char **heads = xmalloc(nr_heads * sizeof(*heads));
...@@ -784,12 +784,12 @@ const struct ref *transport_get_remote_refs(struct transport *transport) ...@@ -784,12 +784,12 @@ const struct ref *transport_get_remote_refs(struct transport *transport)
return transport->remote_refs; return transport->remote_refs;
} }
int transport_fetch_refs(struct transport *transport, struct ref *refs) int transport_fetch_refs(struct transport *transport, const struct ref *refs)
{ {
int rc; int rc;
int nr_heads = 0, nr_alloc = 0; int nr_heads = 0, nr_alloc = 0;
struct ref **heads = NULL; const struct ref **heads = NULL;
struct ref *rm; const struct ref *rm;
for (rm = refs; rm; rm = rm->next) { for (rm = refs; rm; rm = rm->next) {
if (rm->peer_ref && if (rm->peer_ref &&
......
...@@ -19,7 +19,7 @@ struct transport { ...@@ -19,7 +19,7 @@ struct transport {
const char *value); const char *value);
struct ref *(*get_refs_list)(struct transport *transport); struct ref *(*get_refs_list)(struct transport *transport);
int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs); int (*fetch)(struct transport *transport, int refs_nr, const struct ref **refs);
int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags);
int (*disconnect)(struct transport *connection); int (*disconnect)(struct transport *connection);
...@@ -68,7 +68,7 @@ int transport_push(struct transport *connection, ...@@ -68,7 +68,7 @@ int transport_push(struct transport *connection,
const struct ref *transport_get_remote_refs(struct transport *transport); const struct ref *transport_get_remote_refs(struct transport *transport);
int transport_fetch_refs(struct transport *transport, struct ref *refs); int transport_fetch_refs(struct transport *transport, const struct ref *refs);
void transport_unlock_pack(struct transport *transport); void transport_unlock_pack(struct transport *transport);
int transport_disconnect(struct transport *transport); int transport_disconnect(struct transport *transport);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册