#include "cache.h"
+#include "repository.h"
#include "commit.h"
#include "walker.h"
#include "http.h"
#include "list.h"
#include "transport.h"
#include "packfile.h"
+#include "object-store.h"
struct alt_base {
char *base;
struct object_request {
struct walker *walker;
- unsigned char sha1[20];
+ struct object_id oid;
struct alt_base *repo;
enum object_request_state state;
struct http_object_request *req;
struct active_request_slot *slot;
struct http_object_request *req;
- req = new_http_object_request(obj_req->repo->base, obj_req->sha1);
+ req = new_http_object_request(obj_req->repo->base, &obj_req->oid);
if (req == NULL) {
obj_req->state = ABORTED;
return;
return;
if (obj_req->req->rename == 0)
- walker_say(obj_req->walker, "got %s\n", sha1_to_hex(obj_req->sha1));
+ walker_say(obj_req->walker, "got %s\n", oid_to_hex(&obj_req->oid));
}
static void process_object_response(void *callback_data)
list_for_each_safe(pos, tmp, head) {
obj_req = list_entry(pos, struct object_request, node);
if (obj_req->state == WAITING) {
- if (has_sha1_file(obj_req->sha1))
+ if (has_object_file(&obj_req->oid))
obj_req->state = COMPLETE;
else {
start_object_request(walker, obj_req);
newreq = xmalloc(sizeof(*newreq));
newreq->walker = walker;
- hashcpy(newreq->sha1, sha1);
+ hashcpy(newreq->oid.hash, sha1);
newreq->repo = data->alt;
newreq->state = WAITING;
newreq->req = NULL;
list_for_each(pos, head) {
obj_req = list_entry(pos, struct object_request, node);
- if (!hashcmp(obj_req->sha1, sha1))
+ if (hasheq(obj_req->oid.hash, sha1))
break;
}
if (obj_req == NULL)
return error("Couldn't find request for %s in the queue", hex);
- if (has_sha1_file(obj_req->sha1)) {
+ if (has_object_file(&obj_req->oid)) {
if (obj_req->req != NULL)
abort_http_object_request(obj_req->req);
abort_object_request(obj_req);
} else if (req->zret != Z_STREAM_END) {
walker->corrupt_object_found++;
ret = error("File %s (%s) corrupt", hex, req->url);
- } else if (hashcmp(obj_req->sha1, req->real_sha1)) {
+ } else if (!oideq(&obj_req->oid, &req->real_oid)) {
ret = error("File %s has bad hash", hex);
} else if (req->rename < 0) {
struct strbuf buf = STRBUF_INIT;
- sha1_file_name(&buf, req->sha1);
+ loose_object_path(the_repository, &buf, &req->oid);
ret = error("unable to write sha1 filename %s", buf.buf);
strbuf_release(&buf);
}