]> git.ipfire.org Git - thirdparty/git.git/blobdiff - http-push.c
environment.h: move declarations for environment.c functions from cache.h
[thirdparty/git.git] / http-push.c
index b4aeae9e2695369c648ba615e182ab5c3f08561b..40373bc4863535e3d042023a6cf508af87577f75 100644 (file)
@@ -1,4 +1,6 @@
 #include "cache.h"
+#include "environment.h"
+#include "hex.h"
 #include "repository.h"
 #include "commit.h"
 #include "tag.h"
@@ -253,7 +255,7 @@ static void start_fetch_loose(struct transfer_request *request)
        struct http_object_request *obj_req;
 
        obj_req = new_http_object_request(repo->url, &request->obj->oid);
-       if (obj_req == NULL) {
+       if (!obj_req) {
                request->state = ABORTED;
                return;
        }
@@ -318,7 +320,7 @@ static void start_fetch_packed(struct transfer_request *request)
        fprintf(stderr, " which contains %s\n", oid_to_hex(&request->obj->oid));
 
        preq = new_http_pack_request(target->hash, repo->url);
-       if (preq == NULL) {
+       if (!preq) {
                repo->can_update_info_refs = 0;
                return;
        }
@@ -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 %"PRIuMAX , type_name(type), (uintmax_t)len) + 1;
+       hdrlen = format_object_header(hdr, sizeof(hdr), type, len);
 
        /* Set it up */
        git_deflate_init(&stream, zlib_compression_level);
@@ -520,7 +522,7 @@ static void finish_request(struct transfer_request *request)
        /* Keep locks active */
        check_locks();
 
-       if (request->headers != NULL)
+       if (request->headers)
                curl_slist_free_all(request->headers);
 
        /* URL is reused for MOVE after PUT and used during FETCH */
@@ -783,7 +785,7 @@ xml_start_tag(void *userData, const char *name, const char **atts)
        const char *c = strchr(name, ':');
        int old_namelen, new_len;
 
-       if (c == NULL)
+       if (!c)
                c = name;
        else
                c++;
@@ -811,7 +813,7 @@ xml_end_tag(void *userData, const char *name)
 
        ctx->userFunc(ctx, 1);
 
-       if (c == NULL)
+       if (!c)
                c = name;
        else
                c++;
@@ -1689,7 +1691,6 @@ int cmd_main(int argc, const char **argv)
        struct refspec rs = REFSPEC_INIT_PUSH;
        struct remote_lock *ref_lock = NULL;
        struct remote_lock *info_ref_lock = NULL;
-       struct rev_info revs;
        int delete_branch = 0;
        int force_delete = 0;
        int objects_to_send;
@@ -1825,6 +1826,7 @@ int cmd_main(int argc, const char **argv)
 
        new_refs = 0;
        for (ref = remote_refs; ref; ref = ref->next) {
+               struct rev_info revs;
                struct strvec commit_argv = STRVEC_INIT;
 
                if (!ref->peer_ref)
@@ -1893,7 +1895,7 @@ int cmd_main(int argc, const char **argv)
 
                /* Lock remote branch ref */
                ref_lock = lock_remote(ref->name, LOCK_TIME);
-               if (ref_lock == NULL) {
+               if (!ref_lock) {
                        fprintf(stderr, "Unable to lock remote branch %s\n",
                                ref->name);
                        if (helper_status)
@@ -1941,6 +1943,7 @@ int cmd_main(int argc, const char **argv)
                unlock_remote(ref_lock);
                check_locks();
                strvec_clear(&commit_argv);
+               release_revisions(&revs);
        }
 
        /* Update remote server info if appropriate */