pdfdir = $(docdir)
mandir = $(prefix)/share/man
SHA1_HEADER = <openssl/sha.h>
-GIT_VER = 2.40.1
+GIT_VER = 2.41.0
GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz
INSTALL = install
COPYTREE = cp -r
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",
#ifndef CGIT_H
#define CGIT_H
+#include <stdbool.h>
#include <git-compat-util.h>
-#include <stdbool.h>
+#include <archive.h>
#include <cache.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 <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
-Subproject commit 0d1bd1dfb37ef25e1911777c94129fc769ffec38
+Subproject commit fe86abd7511a9a6862d5706c6fa1d9b57a63ba09
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;
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;
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;
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;
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;
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;
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(" ");
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));
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);
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;
.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;
.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) {
}
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';
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;
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);
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;
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);
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;
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;
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;
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);
/* 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;
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);
}
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;
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;
}
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;
"%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;
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;
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;
}
* 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);
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]];
{
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;
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;
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);
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;
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;
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;
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));
}
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;
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;