http-walker: convert struct object_request to use struct object_id

Convert struct object_request to use struct object_id by updating the definition and applying the following semantic patch, plus the standard object_id transforms: @@ struct object_request E1; @@ - E1.sha1 + E1.oid.hash @@ struct object_request *E1; @@ - E1->sha1 + E1->oid.hash Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Mar 12, 2018 at 02:27 UTC 16f0705df107410db8454f3726c49d8c488853c9
1 file changed +8 -8
http-walker.c
+8 -8
@@ -22,7 +22,7 @@ enum object_request_state {
22
23 struct object_request {
24 struct walker *walker;
25 - unsigned char sha1[20];
25 + struct object_id oid;
26 struct alt_base *repo;
27 enum object_request_state state;
28 struct http_object_request *req;
@@ -56,7 +56,7 @@ static void start_object_request(struct walker *walker,
56 struct active_request_slot *slot;
57 struct http_object_request *req;
58
59 - req = new_http_object_request(obj_req->repo->base, obj_req->sha1);
59 + req = new_http_object_request(obj_req->repo->base, obj_req->oid.hash);
60 if (req == NULL) {
61 obj_req->state = ABORTED;
62 return;
@@ -82,7 +82,7 @@ static void finish_object_request(struct object_request *obj_req)
82 return;
83
84 if (obj_req->req->rename == 0)
85 - walker_say(obj_req->walker, "got %s\n", sha1_to_hex(obj_req->sha1));
85 + walker_say(obj_req->walker, "got %s\n", oid_to_hex(&obj_req->oid));
86 }
87
88 static void process_object_response(void *callback_data)
@@ -129,7 +129,7 @@ static int fill_active_slot(struct walker *walker)
129 list_for_each_safe(pos, tmp, head) {
130 obj_req = list_entry(pos, struct object_request, node);
131 if (obj_req->state == WAITING) {
132 - if (has_sha1_file(obj_req->sha1))
132 + if (has_sha1_file(obj_req->oid.hash))
133 obj_req->state = COMPLETE;
134 else {
135 start_object_request(walker, obj_req);
@@ -148,7 +148,7 @@ static void prefetch(struct walker *walker, unsigned char *sha1)
148
149 newreq = xmalloc(sizeof(*newreq));
150 newreq->walker = walker;
151 - hashcpy(newreq->sha1, sha1);
151 + hashcpy(newreq->oid.hash, sha1);
152 newreq->repo = data->alt;
153 newreq->state = WAITING;
154 newreq->req = NULL;
@@ -481,13 +481,13 @@ static int fetch_object(struct walker *walker, unsigned char *sha1)
481
482 list_for_each(pos, head) {
483 obj_req = list_entry(pos, struct object_request, node);
484 - if (!hashcmp(obj_req->sha1, sha1))
484 + if (!hashcmp(obj_req->oid.hash, sha1))
485 break;
486 }
487 if (obj_req == NULL)
488 return error("Couldn't find request for %s in the queue", hex);
489
490 - if (has_sha1_file(obj_req->sha1)) {
490 + if (has_sha1_file(obj_req->oid.hash)) {
491 if (obj_req->req != NULL)
492 abort_http_object_request(obj_req->req);
493 abort_object_request(obj_req);
@@ -541,7 +541,7 @@ static int fetch_object(struct walker *walker, unsigned char *sha1)
541 } else if (req->zret != Z_STREAM_END) {
542 walker->corrupt_object_found++;
543 ret = error("File %s (%s) corrupt", hex, req->url);
544 - } else if (hashcmp(obj_req->sha1, req->real_sha1)) {
544 + } else if (hashcmp(obj_req->oid.hash, req->real_sha1)) {
545 ret = error("File %s has bad hash", hex);
546 } else if (req->rename < 0) {
547 struct strbuf buf = STRBUF_INIT;