]> git.ipfire.org Git - thirdparty/git.git/blobdiff - http-backend.c
path: optimize common dir checking
[thirdparty/git.git] / http-backend.c
index 6bf139b76873bd8553652a4658e6629b24aeeacb..bac40ef6e6e3566a0ceda81303a6ebb769ac520d 100644 (file)
@@ -92,7 +92,7 @@ static void hdr_int(const char *name, uintmax_t value)
 
 static void hdr_date(const char *name, unsigned long when)
 {
-       const char *value = show_date(when, 0, DATE_RFC2822);
+       const char *value = show_date(when, 0, DATE_MODE(RFC2822));
        hdr_str(name, value);
 }
 
@@ -164,7 +164,7 @@ static void send_strbuf(const char *type, struct strbuf *buf)
 
 static void send_local_file(const char *the_type, const char *name)
 {
-       const char *p = git_path("%s", name);
+       char *p = git_pathdup("%s", name);
        size_t buf_alloc = 8192;
        char *buf = xmalloc(buf_alloc);
        int fd;
@@ -191,6 +191,7 @@ static void send_local_file(const char *the_type, const char *name)
        }
        close(fd);
        free(buf);
+       free(p);
 }
 
 static void get_text_file(char *name)
@@ -421,16 +422,16 @@ static void run_service(const char **argv, int buffer_input)
                exit(1);
 }
 
-static int show_text_ref(const char *name, const unsigned char *sha1,
-       int flag, void *cb_data)
+static int show_text_ref(const char *name, const struct object_id *oid,
+                        int flag, void *cb_data)
 {
        const char *name_nons = strip_namespace(name);
        struct strbuf *buf = cb_data;
-       struct object *o = parse_object(sha1);
+       struct object *o = parse_object(oid->hash);
        if (!o)
                return 0;
 
-       strbuf_addf(buf, "%s\t%s\n", sha1_to_hex(sha1), name_nons);
+       strbuf_addf(buf, "%s\t%s\n", oid_to_hex(oid), name_nons);
        if (o->type == OBJ_TAG) {
                o = deref_tag(o, name, 0);
                if (!o)
@@ -473,21 +474,21 @@ static void get_info_refs(char *arg)
        strbuf_release(&buf);
 }
 
-static int show_head_ref(const char *refname, const unsigned char *sha1,
-       int flag, void *cb_data)
+static int show_head_ref(const char *refname, const struct object_id *oid,
+                        int flag, void *cb_data)
 {
        struct strbuf *buf = cb_data;
 
        if (flag & REF_ISSYMREF) {
-               unsigned char unused[20];
+               struct object_id unused;
                const char *target = resolve_ref_unsafe(refname,
                                                        RESOLVE_REF_READING,
-                                                       unused, NULL);
+                                                       unused.hash, NULL);
                const char *target_nons = strip_namespace(target);
 
                strbuf_addf(buf, "ref: %s\n", target_nons);
        } else {
-               strbuf_addf(buf, "%s\n", sha1_to_hex(sha1));
+               strbuf_addf(buf, "%s\n", oid_to_hex(oid));
        }
 
        return 0;