hook: add sign-off using "interpret-trailers"
[gitweb.git] / http-push.c
index 9bb5e06482b2dd59411d9f70b49cc4ab72a49c6f..c91f40a610541d6201edf2a2c95b8fef203f3c2f 100644 (file)
@@ -291,8 +291,7 @@ static void start_mkcol(struct transfer_request *request)
                request->state = RUN_MKCOL;
        } else {
                request->state = ABORTED;
-               free(request->url);
-               request->url = NULL;
+               FREE_AND_NULL(request->url);
        }
 }
 #endif
@@ -409,8 +408,7 @@ static void start_put(struct transfer_request *request)
                request->state = RUN_PUT;
        } else {
                request->state = ABORTED;
-               free(request->url);
-               request->url = NULL;
+               FREE_AND_NULL(request->url);
        }
 }
 
@@ -432,8 +430,7 @@ static void start_move(struct transfer_request *request)
                request->state = RUN_MOVE;
        } else {
                request->state = ABORTED;
-               free(request->url);
-               request->url = NULL;
+               FREE_AND_NULL(request->url);
        }
 }
 
@@ -526,8 +523,7 @@ static void finish_request(struct transfer_request *request)
 
        /* URL is reused for MOVE after PUT */
        if (request->state != RUN_PUT) {
-               free(request->url);
-               request->url = NULL;
+               FREE_AND_NULL(request->url);
        }
 
        if (request->state == RUN_MKCOL) {
@@ -718,13 +714,13 @@ static int fetch_indices(void)
        return ret;
 }
 
-static void one_remote_object(const unsigned char *sha1)
+static void one_remote_object(const struct object_id *oid)
 {
        struct object *obj;
 
-       obj = lookup_object(sha1);
+       obj = lookup_object(oid->hash);
        if (!obj)
-               obj = parse_object(sha1);
+               obj = parse_object(oid);
 
        /* Ignore remote objects that don't exist locally */
        if (!obj)
@@ -803,8 +799,7 @@ xml_start_tag(void *userData, const char *name, const char **atts)
        }
        xsnprintf(ctx->name + old_namelen, ctx->len - old_namelen, ".%s", c);
 
-       free(ctx->cdata);
-       ctx->cdata = NULL;
+       FREE_AND_NULL(ctx->cdata);
 
        ctx->userFunc(ctx, 0);
 }
@@ -932,8 +927,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
                free(lock->token);
                free(lock->owner);
                free(url);
-               free(lock);
-               lock = NULL;
+               FREE_AND_NULL(lock);
        } else {
                lock->url = url;
                lock->start_time = time(NULL);
@@ -1013,26 +1007,26 @@ static void remote_ls(const char *path, int flags,
                      void *userData);
 
 /* extract hex from sharded "xx/x{40}" filename */
-static int get_sha1_hex_from_objpath(const char *path, unsigned char *sha1)
+static int get_oid_hex_from_objpath(const char *path, struct object_id *oid)
 {
-       char hex[40];
+       char hex[GIT_MAX_HEXSZ];
 
-       if (strlen(path) != 41)
+       if (strlen(path) != GIT_SHA1_HEXSZ + 1)
                return -1;
 
        memcpy(hex, path, 2);
        path += 2;
        path++; /* skip '/' */
-       memcpy(hex, path, 38);
+       memcpy(hex, path, GIT_SHA1_HEXSZ - 2);
 
-       return get_sha1_hex(hex, sha1);
+       return get_oid_hex(hex, oid);
 }
 
 static void process_ls_object(struct remote_ls_ctx *ls)
 {
        unsigned int *parent = (unsigned int *)ls->userData;
        const char *path = ls->dentry_name;
-       unsigned char sha1[20];
+       struct object_id oid;
 
        if (!strcmp(ls->path, ls->dentry_name) && (ls->flags & IS_DIR)) {
                remote_dir_exists[*parent] = 1;
@@ -1040,10 +1034,10 @@ static void process_ls_object(struct remote_ls_ctx *ls)
        }
 
        if (!skip_prefix(path, "objects/", &path) ||
-           get_sha1_hex_from_objpath(path, sha1))
+           get_oid_hex_from_objpath(path, &oid))
                return;
 
-       one_remote_object(sha1);
+       one_remote_object(&oid);
 }
 
 static void process_ls_ref(struct remote_ls_ctx *ls)
@@ -1105,8 +1099,7 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
                        ls->dentry_flags |= IS_DIR;
                }
        } else if (!strcmp(ctx->name, DAV_PROPFIND_RESP)) {
-               free(ls->dentry_name);
-               ls->dentry_name = NULL;
+               FREE_AND_NULL(ls->dentry_name);
                ls->dentry_flags = 0;
        }
 }
@@ -1312,7 +1305,7 @@ 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->hash), p);
+                       p = process_tree(lookup_tree(entry.oid), p);
                        break;
                case OBJ_BLOB:
                        p = process_blob(lookup_blob(entry.oid), p);
@@ -1462,7 +1455,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
                return;
        }
 
-       o = parse_object(ref->old_oid.hash);
+       o = parse_object(&ref->old_oid);
        if (!o) {
                fprintf(stderr,
                        "Unable to parse object %s for remote ref %s\n",
@@ -1547,8 +1540,7 @@ static void fetch_symref(const char *path, char **symref, struct object_id *oid)
                    curl_errorstr);
        free(url);
 
-       free(*symref);
-       *symref = NULL;
+       FREE_AND_NULL(*symref);
        oidclr(oid);
 
        if (buffer.len == 0)