{"thread":{"id":"18519","subject":"[PATCH 1/5] Allow late reporting of fetched hashes","startedAt":"2009-03-25T03:04:07Z","lastAt":"2009-03-25T03:04:07Z","messageCount":1,"participants":["Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"109298","messageId":"alpine.LNX.1.00.0903242303070.19665@iabervon.org","threadId":"18519","inReplyTo":null,"subject":"[PATCH 1/5] Allow late reporting of fetched hashes","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-03-25T03:04:07Z","receivedAt":"2009-03-25T03:04:07Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Some future transports (in particular, foreign VCS importers) will\nonly report the hashes of new commits when the objects are also\navailable. In preparation, allow fetch_refs() to modify the refs it\ngets (in particular, the remote side's sha1), and treat the null sha1,\nwhen reported by get_ref_list(), as different from any value,\nincluding itself (which, when local, indicates that the local version\ndoesn't exist yet).\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\n builtin-clone.c |    6 ++++--\n transport.c     |   17 +++++++++--------\n transport.h     |    4 ++--\n 3 files changed, 15 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex 0031b5f..ab51974 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -485,8 +485,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\t\t\t\t     option_upload_pack);\n \n \t\trefs = transport_get_remote_refs(transport);\n-\t\tif(refs)\n-\t\t\ttransport_fetch_refs(transport, refs);\n+\t\tif (refs) {\n+\t\t\tstruct ref *ref_cpy = copy_ref_list(refs);\n+\t\t\ttransport_fetch_refs(transport, ref_cpy);\n+\t\t}\n \t}\n \n \tif (refs) {\ndiff --git a/transport.c b/transport.c\nindex 3dfb03c..26c578e 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -207,7 +207,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)\n }\n \n static int fetch_objs_via_rsync(struct transport *transport,\n-\t\t\t\tint nr_objs, const struct ref **to_fetch)\n+\t\t\t\tint nr_objs, struct ref **to_fetch)\n {\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct child_process rsync;\n@@ -356,7 +356,7 @@ static int rsync_transport_push(struct transport *transport,\n \n #ifndef NO_CURL /* http fetch is the only user */\n static int fetch_objs_via_walker(struct transport *transport,\n-\t\t\t\t int nr_objs, const struct ref **to_fetch)\n+\t\t\t\t int nr_objs, struct ref **to_fetch)\n {\n \tchar *dest = xstrdup(transport->url);\n \tstruct walker *walker = transport->data;\n@@ -523,7 +523,7 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)\n }\n \n static int fetch_objs_via_curl(struct transport *transport,\n-\t\t\t\t int nr_objs, const struct ref **to_fetch)\n+\t\t\t\t int nr_objs, struct ref **to_fetch)\n {\n \tif (!transport->data)\n \t\ttransport->data = get_http_walker(transport->url,\n@@ -563,7 +563,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport, int for_pus\n }\n \n static int fetch_refs_from_bundle(struct transport *transport,\n-\t\t\t       int nr_heads, const struct ref **to_fetch)\n+\t\t\t       int nr_heads, struct ref **to_fetch)\n {\n \tstruct bundle_transport_data *data = transport->data;\n \treturn unbundle(&data->header, data->fd);\n@@ -641,7 +641,7 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus\n }\n \n static int fetch_refs_via_pack(struct transport *transport,\n-\t\t\t       int nr_heads, const struct ref **to_fetch)\n+\t\t\t       int nr_heads, struct ref **to_fetch)\n {\n \tstruct git_transport_data *data = transport->data;\n \tchar **heads = xmalloc(nr_heads * sizeof(*heads));\n@@ -1046,15 +1046,16 @@ const struct ref *transport_get_remote_refs(struct transport *transport)\n \treturn transport->remote_refs;\n }\n \n-int transport_fetch_refs(struct transport *transport, const struct ref *refs)\n+int transport_fetch_refs(struct transport *transport, struct ref *refs)\n {\n \tint rc;\n \tint nr_heads = 0, nr_alloc = 0;\n-\tconst struct ref **heads = NULL;\n-\tconst struct ref *rm;\n+\tstruct ref **heads = NULL;\n+\tstruct ref *rm;\n \n \tfor (rm = refs; rm; rm = rm->next) {\n \t\tif (rm->peer_ref &&\n+\t\t    !is_null_sha1(rm->old_sha1) &&\n \t\t    !hashcmp(rm->peer_ref->old_sha1, rm->old_sha1))\n \t\t\tcontinue;\n \t\tALLOC_GROW(heads, nr_heads + 1, nr_alloc);\ndiff --git a/transport.h b/transport.h\nindex b1c2252..489e96a 100644\n--- a/transport.h\n+++ b/transport.h\n@@ -19,7 +19,7 @@ struct transport {\n \t\t\t  const char *value);\n \n \tstruct ref *(*get_refs_list)(struct transport *transport, int for_push);\n-\tint (*fetch)(struct transport *transport, int refs_nr, const struct ref **refs);\n+\tint (*fetch)(struct transport *transport, int refs_nr, struct ref **refs);\n \tint (*push_refs)(struct transport *transport, struct ref *refs, int flags);\n \tint (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags);\n \n@@ -71,7 +71,7 @@ int transport_push(struct transport *connection,\n \n const struct ref *transport_get_remote_refs(struct transport *transport);\n \n-int transport_fetch_refs(struct transport *transport, const struct ref *refs);\n+int transport_fetch_refs(struct transport *transport, struct ref *refs);\n void transport_unlock_pack(struct transport *transport);\n int transport_disconnect(struct transport *transport);\n \n-- \n1.6.2.1.476.g9bf04b\n"}]}