diff options
author | Arjun Satarkar <me@arjunsatarkar.net> | 2025-03-01 20:14:47 +0000 |
---|---|---|
committer | Arjun Satarkar <me@arjunsatarkar.net> | 2025-03-01 20:15:35 +0000 |
commit | d8cfda459f1b413f0800c4cd6bb0a31dfad817c5 (patch) | |
tree | df40863ac7725c3a5a5715038d072549fd5ef290 | |
parent | 22cbd28d05369730b56d85ec75a836a7cf909513 (diff) | |
parent | 09d24d7cd0b7e85633f2f43808b12871bb209d69 (diff) |
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | cgit.c | 10 | ||||
-rw-r--r-- | cgit.h | 34 | ||||
-rw-r--r-- | filter.c | 6 | ||||
m--------- | git | 0 | ||||
-rw-r--r-- | parsing.c | 4 | ||||
-rw-r--r-- | scan-tree.c | 2 | ||||
-rw-r--r-- | shared.c | 19 | ||||
-rw-r--r-- | ui-atom.c | 4 | ||||
-rw-r--r-- | ui-blame.c | 14 | ||||
-rw-r--r-- | ui-blob.c | 12 | ||||
-rw-r--r-- | ui-clone.c | 5 | ||||
-rw-r--r-- | ui-commit.c | 4 | ||||
-rw-r--r-- | ui-diff.c | 18 | ||||
-rw-r--r-- | ui-log.c | 11 | ||||
-rw-r--r-- | ui-patch.c | 10 | ||||
-rw-r--r-- | ui-plain.c | 8 | ||||
-rw-r--r-- | ui-refs.c | 11 | ||||
-rw-r--r-- | ui-shared.c | 20 | ||||
-rw-r--r-- | ui-shared.h | 2 | ||||
-rw-r--r-- | ui-snapshot.c | 16 | ||||
-rw-r--r-- | ui-stats.c | 12 | ||||
-rw-r--r-- | ui-tag.c | 4 | ||||
-rw-r--r-- | ui-tree.c | 10 |
24 files changed, 150 insertions, 88 deletions
@@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = <openssl/sha.h> -GIT_VER = 2.39.0 +GIT_VER = 2.46.0 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "cache.h" #include "cmd.h" @@ -473,7 +475,8 @@ static char *find_default_branch(struct cgit_repo *repo) info.req_ref = repo->defbranch; info.first_ref = NULL; info.match = 0; - for_each_branch_ref(find_current_ref, &info); + refs_for_each_branch_ref(get_main_ref_store(the_repository), + find_current_ref, &info); if (info.match) ref = info.req_ref; else @@ -490,7 +493,8 @@ static char *guess_defbranch(void) const char *ref, *refname; struct object_id oid; - ref = resolve_ref_unsafe("HEAD", 0, &oid, NULL); + ref = refs_resolve_ref_unsafe(get_main_ref_store(the_repository), + "HEAD", 0, &oid, NULL); if (!ref || !skip_prefix(ref, "refs/heads/", &refname)) return "master"; return xstrdup(refname); @@ -631,7 +635,7 @@ static int prepare_repo_cmd(int nongit) return 1; } - if (get_oid(ctx.qry.head, &oid)) { + if (repo_get_oid(the_repository, ctx.qry.head, &oid)) { char *old_head = ctx.qry.head; ctx.qry.head = xstrdup(ctx.repo->defbranch); cgit_print_error_page(404, "Not found", @@ -1,31 +1,35 @@ #ifndef CGIT_H #define CGIT_H +#include <stdbool.h> #include <git-compat-util.h> -#include <stdbool.h> -#include <cache.h> +#include <archive.h> +#include <commit.h> +#include <diffcore.h> +#include <diff.h> +#include <environment.h> +#include <graph.h> #include <grep.h> +#include <hex.h> +#include <log-tree.h> +#include <notes.h> #include <object.h> +#include <object-name.h> #include <object-store.h> -#include <tree.h> -#include <commit.h> -#include <tag.h> -#include <diff.h> -#include <diffcore.h> -#include <strvec.h> +#include <path.h> #include <refs.h> #include <revision.h> -#include <log-tree.h> -#include <archive.h> +#include <setup.h> #include <string-list.h> +#include <strvec.h> +#include <tag.h> +#include <tree.h> +#include <utf8.h> +#include <wrapper.h> #include <xdiff-interface.h> #include <xdiff/xdiff.h> -#include <utf8.h> -#include <notes.h> -#include <graph.h> -#include <inttypes.h> /* Add isgraph(x) to Git's sane ctype support (see git-compat-util.h) */ #undef isgraph @@ -65,7 +69,7 @@ typedef enum { struct cgit_filter { int (*open)(struct cgit_filter *, va_list ap); int (*close)(struct cgit_filter *); - void (*fprintf)(struct cgit_filter *, FILE *, const char *prefix); + void (*fprintfp)(struct cgit_filter *, FILE *, const char *prefix); void (*cleanup)(struct cgit_filter *); int argument_count; }; @@ -128,7 +128,7 @@ void cgit_exec_filter_init(struct cgit_exec_filter *filter, char *cmd, char **ar memset(filter, 0, sizeof(*filter)); filter->base.open = open_exec_filter; filter->base.close = close_exec_filter; - filter->base.fprintf = fprintf_exec_filter; + filter->base.fprintfp = fprintf_exec_filter; filter->base.cleanup = cleanup_exec_filter; filter->cmd = cmd; filter->argv = argv; @@ -353,7 +353,7 @@ static struct cgit_filter *new_lua_filter(const char *cmd, int argument_count) memset(filter, 0, sizeof(*filter)); filter->base.open = open_lua_filter; filter->base.close = close_lua_filter; - filter->base.fprintf = fprintf_lua_filter; + filter->base.fprintfp = fprintf_lua_filter; filter->base.cleanup = cleanup_lua_filter; filter->base.argument_count = argument_count; filter->script_file = xstrdup(cmd); @@ -385,7 +385,7 @@ int cgit_close_filter(struct cgit_filter *filter) void cgit_fprintf_filter(struct cgit_filter *filter, FILE *f, const char *prefix) { - filter->fprintf(filter, f, prefix); + filter->fprintfp(filter, f, prefix); } diff --git a/git b/git -Subproject c48035d29b4e524aed3a32f0403676f0d912886 +Subproject 39bf06adf96da25b87c9aa7d35a32ef3683eb4a @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" /* @@ -198,7 +200,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) const char *p; struct taginfo *ret = NULL; - data = read_object_file(&tag->object.oid, &type, &size); + data = repo_read_object_file(the_repository, &tag->object.oid, &type, &size); if (!data || type != OBJ_TAG) goto cleanup; diff --git a/scan-tree.c b/scan-tree.c index 6a2f65a..84da86e 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -54,7 +54,7 @@ static void scan_tree_repo_config(const char *name, const char *value) config_fn(repo, name, value); } -static int gitconfig_config(const char *key, const char *value, void *cb) +static int gitconfig_config(const char *key, const char *value, const struct config_context *, void *cb) { const char *name; @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" struct cgit_repolist cgit_repolist; @@ -241,7 +243,7 @@ static int load_mmfile(mmfile_t *file, const struct object_id *oid) file->ptr = (char *)""; file->size = 0; } else { - file->ptr = read_object_file(oid, &type, + file->ptr = repo_read_object_file(the_repository, oid, &type, (unsigned long *)&file->size); } return 1; @@ -343,7 +345,7 @@ void cgit_diff_tree(const struct object_id *old_oid, struct diff_options opt; struct pathspec_item *item; - diff_setup(&opt); + repo_diff_setup(the_repository, &opt); opt.output_format = DIFF_FORMAT_CALLBACK; opt.detect_rename = 1; opt.rename_limit = ctx.cfg.renamelimit; @@ -539,7 +541,9 @@ char *expand_macros(const char *txt) char *get_mimetype_for_filename(const char *filename) { - char *ext, *mimetype, *token, line[1024], *saveptr; + char *ext, *mimetype, line[1024]; + struct string_list list = STRING_LIST_INIT_NODUP; + int i; FILE *file; struct string_list_item *mime; @@ -564,13 +568,16 @@ char *get_mimetype_for_filename(const char *filename) while (fgets(line, sizeof(line), file)) { if (!line[0] || line[0] == '#') continue; - mimetype = strtok_r(line, " \t\r\n", &saveptr); - while ((token = strtok_r(NULL, " \t\r\n", &saveptr))) { - if (!strcasecmp(ext, token)) { + string_list_split_in_place(&list, line, " \t\r\n", -1); + string_list_remove_empty_items(&list, 0); + mimetype = list.items[0].string; + for (i = 1; i < list.nr; i++) { + if (!strcasecmp(ext, list.items[i].string)) { fclose(file); return xstrdup(mimetype); } } + string_list_clear(&list, 0); } fclose(file); return NULL; @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-atom.h" #include "html.h" @@ -97,7 +99,7 @@ void cgit_print_atom(char *tip, const char *path, int max_count) argv[argc++] = path; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.verbose_header = 1; @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-blame.h" #include "html.h" @@ -49,12 +51,12 @@ static void emit_blame_entry_hash(struct blame_entry *ent) char *detail = emit_suspect_detail(suspect); html("<span class='oid'>"); - cgit_commit_link(find_unique_abbrev(oid, DEFAULT_ABBREV), detail, + cgit_commit_link(repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV), detail, NULL, ctx.qry.head, oid_to_hex(oid), suspect->path); html("</span>"); free(detail); - if (!parse_commit(suspect->commit) && suspect->commit->parents) { + if (!repo_parse_commit(the_repository, suspect->commit) && suspect->commit->parents) { struct commit *parent = suspect->commit->parents->item; html(" "); @@ -126,7 +128,7 @@ static void print_object(const struct object_id *oid, const char *path, return; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); @@ -135,7 +137,7 @@ static void print_object(const struct object_id *oid, const char *path, strvec_push(&rev_argv, "blame"); strvec_push(&rev_argv, rev); - init_revisions(&revs, NULL); + repo_init_revisions(the_repository, &revs, NULL); revs.diffopt.flags.allow_textconv = 1; setup_revisions(rev_argv.nr, rev_argv.v, &revs, NULL); init_scoreboard(&sb); @@ -287,13 +289,13 @@ void cgit_print_blame(void) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); return; @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-blob.h" #include "html.h" @@ -52,7 +54,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) .file_only = file_only }; - if (get_oid(ref, &oid)) + if (repo_get_oid(the_repository, ref, &oid)) goto done; if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) goto done; @@ -87,7 +89,7 @@ int cgit_print_file(char *path, const char *head, int file_only) .file_only = file_only }; - if (get_oid(head, &oid)) + if (repo_get_oid(the_repository, head, &oid)) return -1; type = oid_object_info(the_repository, &oid, &size); if (type == OBJ_COMMIT) { @@ -100,7 +102,7 @@ int cgit_print_file(char *path, const char *head, int file_only) } if (type == OBJ_BAD) return -1; - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) return -1; buf[size] = '\0'; @@ -138,7 +140,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } } else { - if (get_oid(head, &oid)) { + if (repo_get_oid(the_repository, head, &oid)) { cgit_print_error_page(404, "Not found", "Bad ref: %s", head); return; @@ -160,7 +162,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } - buf = read_object_file(&oid, &type, &size); + buf = repo_read_object_file(the_repository, &oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", hex); @@ -7,6 +7,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-clone.h" #include "html.h" @@ -87,7 +89,8 @@ void cgit_clone_info(void) ctx.page.mimetype = "text/plain"; ctx.page.filename = "info/refs"; cgit_print_http_headers(); - for_each_ref(print_ref_info, NULL); + refs_for_each_ref(get_main_ref_store(the_repository), + print_ref_info, NULL); } void cgit_clone_objects(void) diff --git a/ui-commit.c b/ui-commit.c index 0787237..972e9bc 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-commit.h" #include "html.h" @@ -26,7 +28,7 @@ void cgit_print_commit(char *hex, const char *prefix) if (!hex) hex = ctx.qry.head; - if (get_oid(hex, &oid)) { + if (repo_get_oid(the_repository, hex, &oid)) { cgit_print_error_page(400, "Bad request", "Bad object id: %s", hex); return; @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-diff.h" #include "html.h" @@ -258,8 +260,8 @@ static void header(const struct object_id *oid1, char *path1, int mode1, htmlf("<br/>deleted file mode %.6o", mode1); if (!subproject) { - abbrev1 = xstrdup(find_unique_abbrev(oid1, DEFAULT_ABBREV)); - abbrev2 = xstrdup(find_unique_abbrev(oid2, DEFAULT_ABBREV)); + abbrev1 = xstrdup(repo_find_unique_abbrev(the_repository, oid1, DEFAULT_ABBREV)); + abbrev2 = xstrdup(repo_find_unique_abbrev(the_repository, oid2, DEFAULT_ABBREV)); htmlf("<br/>index %s..%s", abbrev1, abbrev2); free(abbrev1); free(abbrev2); @@ -402,13 +404,13 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_oid(new_rev, new_rev_oid)) { + if (repo_get_oid(the_repository, new_rev, new_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", new_rev); return; } commit = lookup_commit_reference(the_repository, new_rev_oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(new_rev_oid)); return; @@ -416,7 +418,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, new_tree_oid = get_commit_tree_oid(commit); if (old_rev) { - if (get_oid(old_rev, old_rev_oid)) { + if (repo_get_oid(the_repository, old_rev, old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", old_rev); return; @@ -424,12 +426,12 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, } else if (commit->parents && commit->parents->item) { oidcpy(old_rev_oid, &commit->parents->item->object.oid); } else { - oidclr(old_rev_oid); + oidclr(old_rev_oid, the_repository->hash_algo); } if (!is_null_oid(old_rev_oid)) { commit2 = lookup_commit_reference(the_repository, old_rev_oid); - if (!commit2 || parse_commit(commit2)) { + if (!commit2 || repo_parse_commit(the_repository, commit2)) { cgit_print_error_page(404, "Not found", "Bad commit: %s", oid_to_hex(old_rev_oid)); return; @@ -442,7 +444,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (raw) { struct diff_options diffopt; - diff_setup(&diffopt); + repo_diff_setup(the_repository, &diffopt); diffopt.output_format = DIFF_FORMAT_PATCH; diffopt.flags.recursive = 1; diff_setup_done(&diffopt); @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-log.h" #include "html.h" @@ -80,7 +82,8 @@ void show_commit_decorations(struct commit *commit) ctx.qry.showmsg, 0); break; case DECORATION_REF_TAG: - if (!read_ref(deco->name, &oid_tag) && !peel_iterated_oid(&oid_tag, &peeled)) + if (!refs_read_ref(get_main_ref_store(the_repository), deco->name, &oid_tag) && + !peel_iterated_oid(the_repository, &oid_tag, &peeled)) is_annotated = !oideq(&oid_tag, &peeled); cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf); break; @@ -146,7 +149,7 @@ static int show_commit(struct commit *commit, struct rev_info *revs) /* When we get here we have precisely one parent. */ parent = parents->item; /* If we can't parse the commit, let print_commit() report an error. */ - if (parse_commit(parent)) + if (repo_parse_commit(the_repository, parent)) return 1; files = 0; @@ -330,7 +333,7 @@ static const char *disambiguate_ref(const char *ref, int *must_free_result) struct strbuf longref = STRBUF_INIT; strbuf_addf(&longref, "refs/heads/%s", ref); - if (get_oid(longref.buf, &oid) == 0) { + if (repo_get_oid(the_repository, longref.buf, &oid) == 0) { *must_free_result = 1; return strbuf_detach(&longref, NULL); } @@ -430,7 +433,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern if (path) strvec_push(&rev_argv, path); - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.verbose_header = 1; @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-patch.h" #include "html.h" @@ -31,7 +33,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_oid(new_rev, &new_rev_oid)) { + if (repo_get_oid(the_repository, new_rev, &new_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", new_rev); return; @@ -44,7 +46,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, } if (old_rev) { - if (get_oid(old_rev, &old_rev_oid)) { + if (repo_get_oid(the_repository, old_rev, &old_rev_oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", old_rev); return; @@ -57,7 +59,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, } else if (commit->parents && commit->parents->item) { oidcpy(&old_rev_oid, &commit->parents->item->object.oid); } else { - oidclr(&old_rev_oid); + oidclr(&old_rev_oid, the_repository->hash_algo); } if (is_null_oid(&old_rev_oid)) { @@ -78,7 +80,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, "%s%n%n%w(0)%b"; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.verbose_header = 1; rev.diff = 1; @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-plain.h" #include "html.h" @@ -28,7 +30,7 @@ static int print_object(const struct object_id *oid, const char *path) return 0; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; @@ -181,12 +183,12 @@ void cgit_print_plain(void) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Not found"); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Not found"); return; } @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-refs.h" #include "html.h" @@ -155,9 +157,11 @@ void cgit_print_branches(int maxcount) list.refs = NULL; list.alloc = list.count = 0; - for_each_branch_ref(cgit_refs_cb, &list); + refs_for_each_branch_ref(get_main_ref_store(the_repository), + cgit_refs_cb, &list); if (ctx.repo->enable_remote_branches) - for_each_remote_ref(cgit_refs_cb, &list); + refs_for_each_remote_ref(get_main_ref_store(the_repository), + cgit_refs_cb, &list); if (maxcount == 0 || maxcount > list.count) maxcount = list.count; @@ -182,7 +186,8 @@ void cgit_print_tags(int maxcount) list.refs = NULL; list.alloc = list.count = 0; - for_each_tag_ref(cgit_refs_cb, &list); + refs_for_each_tag_ref(get_main_ref_store(the_repository), + cgit_refs_cb, &list); if (list.count == 0) return; qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); diff --git a/ui-shared.c b/ui-shared.c index baea6f2..6fae72d 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-shared.h" #include "cmd.h" @@ -662,12 +664,12 @@ void cgit_submodule_link(const char *class, char *path, const char *rev) path[len - 1] = tail; } -const struct date_mode *cgit_date_mode(enum date_mode_type type) +const struct date_mode cgit_date_mode(enum date_mode_type type) { static struct date_mode mode; mode.type = type; mode.local = ctx.cfg.local_time; - return &mode; + return mode; } static void print_rel_date(time_t t, int tz, double value, @@ -1041,9 +1043,11 @@ static void print_header(void) html("<form method='get'>\n"); cgit_add_hidden_formfields(0, 1, ctx.qry.page); html("<select name='h' onchange='this.form.submit();'>\n"); - for_each_branch_ref(print_branch_option, ctx.qry.head); + refs_for_each_branch_ref(get_main_ref_store(the_repository), + print_branch_option, ctx.qry.head); if (ctx.repo->enable_remote_branches) - for_each_remote_ref(print_branch_option, ctx.qry.head); + refs_for_each_remote_ref(get_main_ref_store(the_repository), + print_branch_option, ctx.qry.head); html("</select> "); html("<input type='submit' value='switch'/>"); html("</form>"); @@ -1188,11 +1192,11 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base, * name starts with {v,V}[0-9] and the prettify mapping is injective, * i.e. each stripped tag can be inverted without ambiguities. */ - if (get_oid(fmt("refs/tags/%s", ref), &oid) == 0 && + if (repo_get_oid(the_repository, fmt("refs/tags/%s", ref), &oid) == 0 && (ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]) && - ((get_oid(fmt("refs/tags/%s", ref + 1), &oid) == 0) + - (get_oid(fmt("refs/tags/v%s", ref + 1), &oid) == 0) + - (get_oid(fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1)) + ((repo_get_oid(the_repository, fmt("refs/tags/%s", ref + 1), &oid) == 0) + + (repo_get_oid(the_repository, fmt("refs/tags/v%s", ref + 1), &oid) == 0) + + (repo_get_oid(the_repository, fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1)) ref++; strbuf_addf(filename, "%s-%s", base, ref); diff --git a/ui-shared.h b/ui-shared.h index 6964873..f12fa99 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -65,7 +65,7 @@ __attribute__((format (printf,1,2))) extern void cgit_print_error(const char *fmt, ...); __attribute__((format (printf,1,0))) extern void cgit_vprint_error(const char *fmt, va_list ap); -extern const struct date_mode *cgit_date_mode(enum date_mode_type type); +extern const struct date_mode cgit_date_mode(enum date_mode_type type); extern void cgit_print_age(time_t t, int tz, time_t max_relative); extern void cgit_print_http_headers(void); extern void cgit_redirect(const char *url, bool permanent); diff --git a/ui-snapshot.c b/ui-snapshot.c index 18361a6..3e38cd5 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-snapshot.h" #include "html.h" @@ -117,7 +119,7 @@ const struct object_id *cgit_snapshot_get_sig(const char *ref, struct notes_tree *tree; struct object_id oid; - if (get_oid(ref, &oid)) + if (repo_get_oid(the_repository, ref, &oid)) return NULL; tree = &snapshot_sig_notes[f - &cgit_snapshot_formats[0]]; @@ -156,7 +158,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, { struct object_id oid; - if (get_oid(hex, &oid)) { + if (repo_get_oid(the_repository, hex, &oid)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", hex); return 1; @@ -190,7 +192,7 @@ static int write_sig(const struct cgit_snapshot_format *format, return 0; } - buf = read_object_file(note, &type, &size); + buf = repo_read_object_file(the_repository, note, &type, &size); if (!buf) { cgit_print_error_page(404, "Not found", "Not found"); return 0; @@ -230,7 +232,7 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo, strbuf_addstr(&snapshot, filename); strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix)); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; reponame = cgit_snapshot_prefix(repo); @@ -242,15 +244,15 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo, strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0); } - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; strbuf_insert(&snapshot, 0, "v", 1); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; strbuf_splice(&snapshot, 0, 1, "V", 1); - if (get_oid(snapshot.buf, &oid) == 0) + if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0) goto out; result = 0; @@ -1,3 +1,13 @@ +/* ui-stats.c: generate stats view + * + * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com> + * + * Licensed under GNU General Public License v2 + * (see COPYING for full license text) + */ + +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-stats.h" #include "html.h" @@ -230,7 +240,7 @@ static struct string_list collect_stats(const struct cgit_period *period) argv[4] = ctx.qry.path; argc += 2; } - init_revisions(&rev, NULL); + repo_init_revisions(the_repository, &rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; rev.max_parents = 1; @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ +#define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-tag.h" #include "html.h" @@ -48,7 +50,7 @@ void cgit_print_tag(char *revname) revname = ctx.qry.head; strbuf_addf(&fullref, "refs/tags/%s", revname); - if (get_oid(fullref.buf, &oid)) { + if (repo_get_oid(the_repository, fullref.buf, &oid)) { cgit_print_error_page(404, "Not found", "Bad tag reference: %s", revname); goto cleanup; @@ -6,6 +6,8 @@ * (see COPYING for full license text) */ + #define USE_THE_REPOSITORY_VARIABLE + #include "cgit.h" #include "ui-tree.h" #include "html.h" @@ -98,7 +100,7 @@ static void print_object(const struct object_id *oid, const char *path, const ch return; } - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { cgit_print_error_page(500, "Internal server error", "Error reading object %s", oid_to_hex(oid)); @@ -242,7 +244,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, } if (S_ISLNK(mode)) { html(" -> "); - buf = read_object_file(oid, &type, &size); + buf = repo_read_object_file(the_repository, oid, &type, &size); if (!buf) { htmlf("Error reading object: %s", oid_to_hex(oid)); goto cleanup; @@ -372,13 +374,13 @@ void cgit_print_tree(const char *rev, char *path) if (!rev) rev = ctx.qry.head; - if (get_oid(rev, &oid)) { + if (repo_get_oid(the_repository, rev, &oid)) { cgit_print_error_page(404, "Not found", "Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(the_repository, &oid); - if (!commit || parse_commit(commit)) { + if (!commit || repo_parse_commit(the_repository, commit)) { cgit_print_error_page(404, "Not found", "Invalid commit reference: %s", rev); return; |