diff options
Diffstat (limited to 'http-push.c')
-rw-r--r-- | http-push.c | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/http-push.c b/http-push.c index 493ee7d719..1bbb0cdb6d 100644 --- a/http-push.c +++ b/http-push.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "repository.h" #include "commit.h" #include "tag.h" #include "blob.h" @@ -6,12 +7,14 @@ #include "refs.h" #include "diff.h" #include "revision.h" -#include "exec_cmd.h" +#include "exec-cmd.h" #include "remote.h" #include "list-objects.h" #include "sigchain.h" #include "argv-array.h" #include "packfile.h" +#include "object-store.h" +#include "commit-reach.h" #ifdef EXPAT_NEEDS_XMLPARSE_H #include <xmlparse.h> @@ -361,8 +364,8 @@ static void start_put(struct transfer_request *request) ssize_t size; git_zstream stream; - unpacked = read_sha1_file(request->obj->oid.hash, &type, &len); - hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), len) + 1; + unpacked = read_object_file(&request->obj->oid, &type, &len); + hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1; /* Set it up */ git_deflate_init(&stream, zlib_compression_level); @@ -719,9 +722,9 @@ static void one_remote_object(const struct object_id *oid) { struct object *obj; - obj = lookup_object(oid->hash); + obj = lookup_object(the_repository, oid->hash); if (!obj) - obj = parse_object(oid); + obj = parse_object(the_repository, oid); /* Ignore remote objects that don't exist locally */ if (!obj) @@ -915,6 +918,10 @@ static struct remote_lock *lock_remote(const char *path, long timeout) lock->timeout = -1; } XML_ParserFree(parser); + } else { + fprintf(stderr, + "error: curl result=%d, HTTP code=%ld\n", + results.curl_result, results.http_code); } } else { fprintf(stderr, "Unable to start LOCK request\n"); @@ -1007,20 +1014,18 @@ static void remote_ls(const char *path, int flags, void (*userFunc)(struct remote_ls_ctx *ls), void *userData); -/* extract hex from sharded "xx/x{40}" filename */ +/* extract hex from sharded "xx/x{38}" filename */ static int get_oid_hex_from_objpath(const char *path, struct object_id *oid) { - char hex[GIT_MAX_HEXSZ]; - if (strlen(path) != GIT_SHA1_HEXSZ + 1) return -1; - memcpy(hex, path, 2); + if (hex_to_bytes(oid->hash, path, 1)) + return -1; path += 2; path++; /* skip '/' */ - memcpy(hex + 2, path, GIT_SHA1_HEXSZ - 2); - return get_oid_hex(hex, oid); + return hex_to_bytes(oid->hash + 1, path, GIT_SHA1_RAWSZ - 1); } static void process_ls_object(struct remote_ls_ctx *ls) @@ -1306,10 +1311,12 @@ static struct object_list **process_tree(struct tree *tree, while (tree_entry(&desc, &entry)) switch (object_type(entry.mode)) { case OBJ_TREE: - p = process_tree(lookup_tree(entry.oid), p); + p = process_tree(lookup_tree(the_repository, entry.oid), + p); break; case OBJ_BLOB: - p = process_blob(lookup_blob(entry.oid), p); + p = process_blob(lookup_blob(the_repository, entry.oid), + p); break; default: /* Subproject commit - not in this repository */ @@ -1328,7 +1335,7 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock) int count = 0; while ((commit = get_revision(revs)) != NULL) { - p = process_tree(commit->tree, p); + p = process_tree(get_commit_tree(commit), p); commit->object.flags |= LOCAL; if (!(commit->object.flags & UNINTERESTING)) count += add_send_request(&commit->object, lock); @@ -1456,7 +1463,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls) return; } - o = parse_object(&ref->old_oid); + o = parse_object(the_repository, &ref->old_oid); if (!o) { fprintf(stderr, "Unable to parse object %s for remote ref %s\n", @@ -1470,7 +1477,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls) oid_to_hex(&ref->old_oid), ls->dentry_name); if (o->type == OBJ_TAG) { - o = deref_tag(o, ls->dentry_name, 0); + o = deref_tag(the_repository, o, ls->dentry_name, 0); if (o) strbuf_addf(buf, "%s\t%s^{}\n", oid_to_hex(&o->oid), ls->dentry_name); @@ -1689,8 +1696,7 @@ int cmd_main(int argc, const char **argv) { struct transfer_request *request; struct transfer_request *next_request; - int nr_refspec = 0; - const char **refspec = NULL; + struct refspec rs = REFSPEC_INIT_PUSH; struct remote_lock *ref_lock = NULL; struct remote_lock *info_ref_lock = NULL; struct rev_info revs; @@ -1753,8 +1759,7 @@ int cmd_main(int argc, const char **argv) } continue; } - refspec = argv; - nr_refspec = argc - i; + refspec_appendn(&rs, argv, argc - i); break; } @@ -1765,7 +1770,7 @@ int cmd_main(int argc, const char **argv) if (!repo->url) usage(http_push_usage); - if (delete_branch && nr_refspec != 1) + if (delete_branch && rs.nr != 1) die("You must specify only one branch name when deleting a remote branch"); setup_git_directory(); @@ -1811,18 +1816,18 @@ int cmd_main(int argc, const char **argv) /* Remove a remote branch if -d or -D was specified */ if (delete_branch) { - if (delete_remote_branch(refspec[0], force_delete) == -1) { + const char *branch = rs.items[i].src; + if (delete_remote_branch(branch, force_delete) == -1) { fprintf(stderr, "Unable to delete remote branch %s\n", - refspec[0]); + branch); if (helper_status) - printf("error %s cannot remove\n", refspec[0]); + printf("error %s cannot remove\n", branch); } goto cleanup; } /* match them up */ - if (match_push_refs(local_refs, &remote_refs, - nr_refspec, (const char **) refspec, push_all)) { + if (match_push_refs(local_refs, &remote_refs, &rs, push_all)) { rc = -1; goto cleanup; } @@ -1854,7 +1859,7 @@ int cmd_main(int argc, const char **argv) continue; } - if (!oidcmp(&ref->old_oid, &ref->peer_ref->new_oid)) { + if (oideq(&ref->old_oid, &ref->peer_ref->new_oid)) { if (push_verbosely) fprintf(stderr, "'%s': up-to-date\n", ref->name); if (helper_status) |