object: add repository argument to object_as_type
[gitweb.git] / http-push.c
index 2669f4bfa1e2e47226f6e58084f35f4a64b21226..d2245cc73802fec76ed8613adf84c3995e70b716 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "repository.h"
 #include "commit.h"
 #include "tag.h"
 #include "blob.h"
@@ -14,6 +15,7 @@
 #include "packfile.h"
 #include "object-store.h"
 
+
 #ifdef EXPAT_NEEDS_XMLPARSE_H
 #include <xmlparse.h>
 #else
@@ -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)
@@ -1459,7 +1461,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",
@@ -1692,8 +1694,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 +1757,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 +1768,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 +1814,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;
        }