diff options
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | cgit.c | 4 | ||||
| -rw-r--r-- | cgit.h | 6 | ||||
| -rw-r--r-- | parsing.c | 2 | ||||
| -rw-r--r-- | shared.c | 6 | ||||
| -rw-r--r-- | ui-blame.c | 12 | ||||
| -rw-r--r-- | ui-blob.c | 51 | ||||
| -rw-r--r-- | ui-clone.c | 14 | ||||
| -rw-r--r-- | ui-plain.c | 11 | ||||
| -rw-r--r-- | ui-shared.c | 4 | ||||
| -rw-r--r-- | ui-snapshot.c | 2 | ||||
| -rw-r--r-- | ui-tree.c | 22 |
12 files changed, 93 insertions, 43 deletions
@@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = <openssl/sha.h> -GIT_VER = 2.46.0 +GIT_VER = 2.51.2 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r @@ -448,8 +448,8 @@ struct refmatch { int match; }; -static int find_current_ref(const char *refname, const struct object_id *oid, - int flags, void *cb_data) +static int find_current_ref(const char *refname, const char *referent, + const struct object_id *oid, int flags, void *cb_data) { struct refmatch *info; @@ -17,7 +17,7 @@ #include <notes.h> #include <object.h> #include <object-name.h> -#include <object-store.h> +#include <odb.h> #include <path.h> #include <refs.h> #include <revision.h> @@ -346,8 +346,8 @@ extern void strbuf_ensure_end(struct strbuf *sb, char c); extern void cgit_add_ref(struct reflist *list, struct refinfo *ref); extern void cgit_free_reflist_inner(struct reflist *list); -extern int cgit_refs_cb(const char *refname, const struct object_id *oid, - int flags, void *cb_data); +extern int cgit_refs_cb(const char *refname, const char *referent, + const struct object_id *oid, int flags, void *cb_data); extern void cgit_free_commitinfo(struct commitinfo *info); extern void cgit_free_taginfo(struct taginfo *info); @@ -200,7 +200,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) const char *p; struct taginfo *ret = NULL; - data = repo_read_object_file(the_repository, &tag->object.oid, &type, &size); + data = odb_read_object(the_repository->objects, &tag->object.oid, &type, &size); if (!data || type != OBJ_TAG) goto cleanup; @@ -212,8 +212,8 @@ void cgit_free_reflist_inner(struct reflist *list) free(list->refs); } -int cgit_refs_cb(const char *refname, const struct object_id *oid, int flags, - void *cb_data) +int cgit_refs_cb(const char *refname, const char *referent, + const struct object_id *oid, int flags, void *cb_data) { struct reflist *list = (struct reflist *)cb_data; struct refinfo *info = cgit_mk_refinfo(refname, oid); @@ -243,7 +243,7 @@ static int load_mmfile(mmfile_t *file, const struct object_id *oid) file->ptr = (char *)""; file->size = 0; } else { - file->ptr = repo_read_object_file(the_repository, oid, &type, + file->ptr = odb_read_object(the_repository->objects, oid, &type, (unsigned long *)&file->size); } return 1; @@ -121,15 +121,15 @@ static void print_object(const struct object_id *oid, const char *path, struct blame_origin *o; struct blame_entry *ent = NULL; - type = oid_object_info(the_repository, oid, &size); - if (type == OBJ_BAD) { - cgit_print_error_page(404, "Not found", "Bad object name: %s", - oid_to_hex(oid)); + if (!odb_has_object(the_repository->objects, oid, 0)) { + cgit_print_error_page(404, "Not found", + "Object %s not found in repository", + oid_to_hex(oid)); return; } - buf = repo_read_object_file(the_repository, oid, &type, &size); - if (!buf) { + buf = odb_read_object(the_repository->objects, oid, &type, &size); + if (!buf || type != OBJ_BLOB) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); return; @@ -38,7 +38,14 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base, int cgit_ref_path_exists(const char *path, const char *ref, int file_only) { struct object_id oid; + enum object_type type; + void *buffer; unsigned long size; + struct object_info oi = { + .typep = &type, + .sizep = &size, + .contentp = &buffer, + }; struct pathspec_item path_items = { .match = xstrdup(path), .len = strlen(path) @@ -56,8 +63,10 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) if (repo_get_oid(the_repository, ref, &oid)) goto done; - if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) - goto done; + if (odb_read_object_info_extended(the_repository->objects, &oid, + &oi, OBJECT_INFO_LOOKUP_REPLACE) < 0 + || type != OBJ_COMMIT) goto done; + read_tree(the_repository, repo_get_commit_tree(the_repository, lookup_commit_reference(the_repository, &oid)), &paths, walk_tree, &walk_tree_ctx); @@ -91,18 +100,28 @@ int cgit_print_file(char *path, const char *head, int file_only) if (repo_get_oid(the_repository, head, &oid)) return -1; - type = oid_object_info(the_repository, &oid, &size); + + struct object_info oi = { + .typep = &type, + .sizep = &size + }; + + if (odb_read_object_info_extended(the_repository->objects, &oid, + &oi, OBJECT_INFO_LOOKUP_REPLACE) < 0) return -1; + if (type == OBJ_COMMIT) { commit = lookup_commit_reference(the_repository, &oid); read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk_tree_ctx); if (!walk_tree_ctx.found_path) return -1; - type = oid_object_info(the_repository, &oid, &size); + + if (odb_read_object_info_extended(the_repository->objects, &oid, + &oi, OBJECT_INFO_LOOKUP_REPLACE) < 0) return -1; } if (type == OBJ_BAD) return -1; - buf = repo_read_object_file(the_repository, &oid, &type, &size); + buf = odb_read_object(the_repository->objects, &oid, &type, &size); if (!buf) return -1; buf[size] = '\0'; @@ -147,13 +166,29 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl } } - type = oid_object_info(the_repository, &oid, &size); + struct object_info oi = { + .typep = &type, + .sizep = &size + }; + + if (odb_read_object_info_extended(the_repository->objects, &oid, + &oi, OBJECT_INFO_LOOKUP_REPLACE) < 0) { + cgit_print_error_page(500, "Internal server error", + "Error reading object %s", hex ? hex : head); + return; + } if ((!hex) && type == OBJ_COMMIT && path) { commit = lookup_commit_reference(the_repository, &oid); read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk_tree_ctx); - type = oid_object_info(the_repository, &oid, &size); + + if (odb_read_object_info_extended(the_repository->objects, &oid, + &oi, OBJECT_INFO_LOOKUP_REPLACE) < 0) { + cgit_print_error_page(500, "Internal server error", + "Error reading object %s", hex ? hex : head); + return; + } } if (type == OBJ_BAD) { @@ -162,7 +197,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } - buf = repo_read_object_file(the_repository, &oid, &type, &size); + buf = odb_read_object(the_repository->objects, &oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", hex); @@ -14,10 +14,10 @@ #include "html.h" #include "ui-shared.h" #include "packfile.h" -#include "object-store.h" +#include "odb.h" -static int print_ref_info(const char *refname, const struct object_id *oid, - int flags, void *cb_data) +static int print_ref_info(const char *refname, const char *referent, + const struct object_id *oid, int flags, void *cb_data) { struct object *obj; @@ -116,7 +116,9 @@ void cgit_clone_objects(void) goto err; } - send_file(git_path("objects/%s", ctx.qry.path)); + char *objpath = repo_git_path(the_repository, "objects/%s", ctx.qry.path); + send_file(objpath); + free(objpath); return; err: @@ -125,5 +127,7 @@ err: void cgit_clone_head(void) { - send_file(git_path("%s", "HEAD")); + char *objpath = repo_git_path(the_repository, "%s", "HEAD"); + send_file(objpath); + free(objpath); } @@ -24,13 +24,18 @@ static int print_object(const struct object_id *oid, const char *path) char *buf, *mimetype; unsigned long size; - type = oid_object_info(the_repository, oid, &size); - if (type == OBJ_BAD) { + struct object_info oi = { + .typep = &type, + .sizep = &size + }; + + if (odb_read_object_info_extended(the_repository->objects, oid, + &oi, OBJECT_INFO_LOOKUP_REPLACE) < 0 || type == OBJ_BAD) { cgit_print_error_page(404, "Not found", "Not found"); return 0; } - buf = repo_read_object_file(the_repository, oid, &type, &size); + buf = odb_read_object(the_repository->objects, oid, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; diff --git a/ui-shared.c b/ui-shared.c index 6fae72d..7c5a19c 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -936,8 +936,8 @@ void cgit_add_clone_urls(void (*fn)(const char *)) add_clone_urls(fn, ctx.cfg.clone_prefix, ctx.repo->url); } -static int print_branch_option(const char *refname, const struct object_id *oid, - int flags, void *cb_data) +static int print_branch_option(const char *refname, const char *referent, + const struct object_id *oid, int flags, void *cb_data) { char *name = (char *)refname; html_option(name, name, ctx.qry.head); diff --git a/ui-snapshot.c b/ui-snapshot.c index 3e38cd5..d157222 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -192,7 +192,7 @@ static int write_sig(const struct cgit_snapshot_format *format, return 0; } - buf = repo_read_object_file(the_repository, note, &type, &size); + buf = odb_read_object(the_repository->objects, note, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; @@ -93,15 +93,15 @@ static void print_object(const struct object_id *oid, const char *path, const ch unsigned long size; bool is_binary; - type = oid_object_info(the_repository, oid, &size); - if (type == OBJ_BAD) { + if (!odb_has_object(the_repository->objects, oid, 0)) { cgit_print_error_page(404, "Not found", - "Bad object name: %s", oid_to_hex(oid)); + "Object %s not found in repository", + oid_to_hex(oid)); return; } - buf = repo_read_object_file(the_repository, oid, &type, &size); - if (!buf) { + buf = odb_read_object(the_repository->objects, oid, &type, &size); + if (!buf || type != OBJ_BLOB) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); return; @@ -217,8 +217,14 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, ctx.qry.path ? "/" : "", name); if (!S_ISGITLINK(mode)) { - type = oid_object_info(the_repository, oid, &size); - if (type == OBJ_BAD) { + + struct object_info oi = { + .typep = &type, + .sizep = &size + }; + + if (odb_read_object_info_extended(the_repository->objects, oid, + &oi, OBJECT_INFO_LOOKUP_REPLACE) < 0 || type == OBJ_BAD) { htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", name, oid_to_hex(oid)); @@ -244,7 +250,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, } if (S_ISLNK(mode)) { html(" -> "); - buf = repo_read_object_file(the_repository, oid, &type, &size); + buf = odb_read_object(the_repository->objects, oid, &type, &size); if (!buf) { htmlf("Error reading object: %s", oid_to_hex(oid)); goto cleanup; |
