diff options
Diffstat (limited to 'http-push.c')
-rw-r--r-- | http-push.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/http-push.c b/http-push.c index 7dcd9daf62..d1f52cbdf6 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,7 +364,7 @@ static void start_put(struct transfer_request *request) ssize_t size; git_zstream stream; - unpacked = read_sha1_file(request->obj->oid.hash, &type, &len); + unpacked = read_object_file(&request->obj->oid, &type, &len); hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1; /* Set it up */ @@ -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) @@ -1308,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 */ @@ -1330,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); @@ -1458,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", @@ -1472,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); @@ -1691,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; @@ -1755,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; } @@ -1767,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(); @@ -1813,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; } @@ -1856,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) @@ -1922,7 +1925,7 @@ int cmd_main(int argc, const char **argv) if (!push_all && !is_null_oid(&ref->old_oid)) argv_array_pushf(&commit_argv, "^%s", oid_to_hex(&ref->old_oid)); - init_revisions(&revs, setup_git_directory()); + repo_init_revisions(the_repository, &revs, setup_git_directory()); setup_revisions(commit_argv.argc, commit_argv.argv, &revs, NULL); revs.edge_hint = 0; /* just in case */ |