sequencer: remove the 'arg' field from todo_item
[gitweb.git] / http-push.c
index 2669f4bfa1e2e47226f6e58084f35f4a64b21226..cd485909127a79afcbb58ef18cd28977b65efb79 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "repository.h"
 #include "commit.h"
 #include "tag.h"
 #include "blob.h"
@@ -13,6 +14,7 @@
 #include "argv-array.h"
 #include "packfile.h"
 #include "object-store.h"
+#include "commit-reach.h"
 
 #ifdef EXPAT_NEEDS_XMLPARSE_H
 #include <xmlparse.h>
@@ -363,7 +365,7 @@ static void start_put(struct transfer_request *request)
        git_zstream stream;
 
        unpacked = read_object_file(&request->obj->oid, &type, &len);
-       hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", type_name(type), len) + 1;
+       hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %"PRIuMAX , type_name(type), (uintmax_t)len) + 1;
 
        /* Set it up */
        git_deflate_init(&stream, zlib_compression_level);
@@ -720,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)
@@ -1309,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 */
@@ -1459,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",
@@ -1473,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);
@@ -1692,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;
@@ -1756,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;
        }
 
@@ -1768,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();
@@ -1814,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;
        }
@@ -1857,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)
@@ -1923,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 */