pdfdir = $(docdir)
mandir = $(prefix)/share/man
SHA1_HEADER = <openssl/sha.h>
-GIT_VER = 2.17.1
+GIT_VER = 2.18.0
GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz
INSTALL = install
COPYTREE = cp -r
-Subproject commit fc54c1af3ec09bab8b8ea09768c2da4069b7f53e
+Subproject commit 53f9a3e157dbbc901a02ac2c73346d375e24978c
const char *p;
struct taginfo *ret = NULL;
- data = read_sha1_file(tag->object.oid.hash, &type, &size);
+ data = read_object_file(&tag->object.oid, &type, &size);
if (!data || type != OBJ_TAG)
goto cleanup;
file->ptr = (char *)"";
file->size = 0;
} else {
- file->ptr = read_sha1_file(oid->hash, &type,
+ file->ptr = read_object_file(oid, &type,
(unsigned long *)&file->size);
}
return 1;
char *detail = emit_suspect_detail(suspect);
html("<span class='sha1'>");
- cgit_commit_link(find_unique_abbrev(oid->hash, DEFAULT_ABBREV), detail,
+ cgit_commit_link(find_unique_abbrev(oid, DEFAULT_ABBREV), detail,
NULL, ctx.qry.head, oid_to_hex(oid), suspect->path);
html("</span>");
free(detail);
int state;
};
-static void print_object(const unsigned char *sha1, const char *path,
+static void print_object(const struct object_id *oid, const char *path,
const char *basename, const char *rev)
{
enum object_type type;
struct blame_origin *o;
struct blame_entry *ent = NULL;
- type = sha1_object_info(sha1, &size);
+ type = oid_object_info(the_repository, oid, &size);
if (type == OBJ_BAD) {
cgit_print_error_page(404, "Not found", "Bad object name: %s",
- sha1_to_hex(sha1));
+ oid_to_hex(oid));
return;
}
- buf = read_sha1_file(sha1, &type, &size);
+ buf = read_object_file(oid, &type, &size);
if (!buf) {
cgit_print_error_page(500, "Internal server error",
- "Error reading object %s", sha1_to_hex(sha1));
+ "Error reading object %s", oid_to_hex(oid));
return;
}
cgit_set_title_from_path(path);
cgit_print_layout_start();
- htmlf("blob: %s (", sha1_to_hex(sha1));
+ htmlf("blob: %s (", oid_to_hex(oid));
cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path);
html(") (");
cgit_tree_link("tree", NULL, NULL, ctx.qry.head, rev, path);
free(buf);
}
-static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+static int walk_tree(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, int stage,
void *cbdata)
{
struct strbuf buffer = STRBUF_INIT;
strbuf_addbuf(&buffer, base);
strbuf_addstr(&buffer, pathname);
- print_object(sha1, buffer.buf, pathname,
+ print_object(oid, buffer.buf, pathname,
walk_tree_ctx->curr_rev);
strbuf_release(&buffer);
walk_tree_ctx->state = 1;
walk_tree_ctx.match_baselen = (path_items.match) ?
basedir_len(path_items.match) : -1;
- read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree,
+ read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree,
&walk_tree_ctx);
if (!walk_tree_ctx.state)
cgit_print_error_page(404, "Not found", "Not found");
unsigned int file_only:1;
};
-static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+static int walk_tree(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, int stage, void *cbdata)
{
struct walk_tree_context *walk_tree_ctx = cbdata;
if (strncmp(base->buf, walk_tree_ctx->match_path, base->len)
|| strcmp(walk_tree_ctx->match_path + base->len, pathname))
return READ_TREE_RECURSIVE;
- hashcpy(walk_tree_ctx->matched_oid->hash, sha1);
+ oidcpy(walk_tree_ctx->matched_oid, oid);
walk_tree_ctx->found_path = 1;
return 0;
}
if (get_oid(ref, &oid))
goto done;
- if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT)
+ if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT)
goto done;
- read_tree_recursive(lookup_commit_reference(&oid)->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(lookup_commit_reference(&oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
done:
free(path_items.match);
if (get_oid(head, &oid))
return -1;
- type = sha1_object_info(oid.hash, &size);
+ type = oid_object_info(the_repository, &oid, &size);
if (type == OBJ_COMMIT) {
commit = lookup_commit_reference(&oid);
- read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.found_path)
return -1;
- type = sha1_object_info(oid.hash, &size);
+ type = oid_object_info(the_repository, &oid, &size);
}
if (type == OBJ_BAD)
return -1;
- buf = read_sha1_file(oid.hash, &type, &size);
+ buf = read_object_file(&oid, &type, &size);
if (!buf)
return -1;
buf[size] = '\0';
}
}
- type = sha1_object_info(oid.hash, &size);
+ type = oid_object_info(the_repository, &oid, &size);
if ((!hex) && type == OBJ_COMMIT && path) {
commit = lookup_commit_reference(&oid);
- read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
- type = sha1_object_info(oid.hash, &size);
+ read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ type = oid_object_info(the_repository, &oid, &size);
}
if (type == OBJ_BAD) {
return;
}
- buf = read_sha1_file(oid.hash, &type, &size);
+ buf = read_object_file(&oid, &type, &size);
if (!buf) {
cgit_print_error_page(500, "Internal server error",
"Error reading object %s", hex);
#include "html.h"
#include "ui-shared.h"
#include "packfile.h"
+#include "object-store.h"
static int print_ref_info(const char *refname, const struct object_id *oid,
int flags, void *cb_data)
ctx.page.mimetype = "text/plain";
ctx.page.filename = "objects/info/packs";
cgit_print_http_headers();
- prepare_packed_git();
- for (pack = packed_git; pack; pack = pack->next) {
+ reprepare_packed_git(the_repository);
+ for (pack = get_packed_git(the_repository); pack; pack = pack->next) {
if (pack->pack_local) {
offset = strrchr(pack->pack_name, '/');
if (offset && offset[1] != '\0')
html(")</td></tr>\n");
html("<tr><th>tree</th><td colspan='2' class='sha1'>");
tmp = xstrdup(hex);
- cgit_tree_link(oid_to_hex(&commit->tree->object.oid), NULL, NULL,
+ cgit_tree_link(oid_to_hex(&commit->maybe_tree->object.oid), NULL, NULL,
ctx.qry.head, tmp, NULL);
if (prefix) {
html(" /");
htmlf("<br/>deleted file mode %.6o", mode1);
if (!subproject) {
- abbrev1 = xstrdup(find_unique_abbrev(oid1->hash, DEFAULT_ABBREV));
- abbrev2 = xstrdup(find_unique_abbrev(oid2->hash, DEFAULT_ABBREV));
+ abbrev1 = xstrdup(find_unique_abbrev(oid1, DEFAULT_ABBREV));
+ abbrev2 = xstrdup(find_unique_abbrev(oid2, DEFAULT_ABBREV));
htmlf("<br/>index %s..%s", abbrev1, abbrev2);
free(abbrev1);
free(abbrev2);
"Bad commit: %s", oid_to_hex(new_rev_oid));
return;
}
- new_tree_oid = &commit->tree->object.oid;
+ new_tree_oid = &commit->maybe_tree->object.oid;
if (old_rev) {
if (get_oid(old_rev, old_rev_oid)) {
"Bad commit: %s", oid_to_hex(old_rev_oid));
return;
}
- old_tree_oid = &commit2->tree->object.oid;
+ old_tree_oid = &commit2->maybe_tree->object.oid;
} else {
old_tree_oid = NULL;
}
rem_lines = 0;
revs->diffopt.flags.recursive = 1;
- diff_tree_oid(&parent->tree->object.oid,
- &commit->tree->object.oid,
+ diff_tree_oid(&parent->maybe_tree->object.oid,
+ &commit->maybe_tree->object.oid,
"", &revs->diffopt);
diffcore_std(&revs->diffopt);
int match;
};
-static int print_object(const unsigned char *sha1, const char *path)
+static int print_object(const struct object_id *oid, const char *path)
{
enum object_type type;
char *buf, *mimetype;
unsigned long size;
- type = sha1_object_info(sha1, &size);
+ type = oid_object_info(the_repository, oid, &size);
if (type == OBJ_BAD) {
cgit_print_error_page(404, "Not found", "Not found");
return 0;
}
- buf = read_sha1_file(sha1, &type, &size);
+ buf = read_object_file(oid, &type, &size);
if (!buf) {
cgit_print_error_page(404, "Not found", "Not found");
return 0;
}
ctx.page.filename = path;
ctx.page.size = size;
- ctx.page.etag = sha1_to_hex(sha1);
+ ctx.page.etag = oid_to_hex(oid);
cgit_print_http_headers();
html_raw(buf, size);
free(mimetype);
return fmtalloc("%.*s/", baselen, base);
}
-static void print_dir(const unsigned char *sha1, const char *base,
+static void print_dir(const struct object_id *oid, const char *base,
int baselen, const char *path)
{
char *fullpath, *slash;
fullpath = buildpath(base, baselen, path);
slash = (fullpath[0] == '/' ? "" : "/");
- ctx.page.etag = sha1_to_hex(sha1);
+ ctx.page.etag = oid_to_hex(oid);
cgit_print_http_headers();
htmlf("<html><head><title>%s", slash);
html_txt(fullpath);
free(fullpath);
}
-static void print_dir_entry(const unsigned char *sha1, const char *base,
+static void print_dir_entry(const struct object_id *oid, const char *base,
int baselen, const char *path, unsigned mode)
{
char *fullpath;
fullpath[strlen(fullpath) - 1] = 0;
html(" <li>");
if (S_ISGITLINK(mode)) {
- cgit_submodule_link(NULL, fullpath, sha1_to_hex(sha1));
+ cgit_submodule_link(NULL, fullpath, oid_to_hex(oid));
} else
cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
fullpath);
html(" </ul>\n</body></html>\n");
}
-static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+static int walk_tree(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, int stage, void *cbdata)
{
struct walk_tree_context *walk_tree_ctx = cbdata;
if (base->len == walk_tree_ctx->match_baselen) {
if (S_ISREG(mode) || S_ISLNK(mode)) {
- if (print_object(sha1, pathname))
+ if (print_object(oid, pathname))
walk_tree_ctx->match = 1;
} else if (S_ISDIR(mode)) {
- print_dir(sha1, base->buf, base->len, pathname);
+ print_dir(oid, base->buf, base->len, pathname);
walk_tree_ctx->match = 2;
return READ_TREE_RECURSIVE;
}
} else if (base->len < INT_MAX && (int)base->len > walk_tree_ctx->match_baselen) {
- print_dir_entry(sha1, base->buf, base->len, pathname, mode);
+ print_dir_entry(oid, base->buf, base->len, pathname, mode);
walk_tree_ctx->match = 2;
} else if (S_ISDIR(mode)) {
return READ_TREE_RECURSIVE;
if (!path_items.match) {
path_items.match = "";
walk_tree_ctx.match_baselen = -1;
- print_dir(commit->tree->object.oid.hash, "", 0, "");
+ print_dir(&commit->maybe_tree->object.oid, "", 0, "");
walk_tree_ctx.match = 2;
}
else
walk_tree_ctx.match_baselen = basedir_len(path_items.match);
- read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
if (!walk_tree_ctx.match)
cgit_print_error_page(404, "Not found", "Not found");
else if (walk_tree_ctx.match == 2)
return 0;
}
- buf = read_sha1_file(note->hash, &type, &size);
+ buf = read_object_file(note, &type, &size);
if (!buf) {
cgit_print_error_page(404, "Not found", "Not found");
return 0;
html("</table>\n");
}
-static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev)
+static void print_object(const struct object_id *oid, char *path, const char *basename, const char *rev)
{
enum object_type type;
char *buf;
unsigned long size;
- type = sha1_object_info(sha1, &size);
+ type = oid_object_info(the_repository, oid, &size);
if (type == OBJ_BAD) {
cgit_print_error_page(404, "Not found",
- "Bad object name: %s", sha1_to_hex(sha1));
+ "Bad object name: %s", oid_to_hex(oid));
return;
}
- buf = read_sha1_file(sha1, &type, &size);
+ buf = read_object_file(oid, &type, &size);
if (!buf) {
cgit_print_error_page(500, "Internal server error",
- "Error reading object %s", sha1_to_hex(sha1));
+ "Error reading object %s", oid_to_hex(oid));
return;
}
cgit_set_title_from_path(path);
cgit_print_layout_start();
- htmlf("blob: %s (", sha1_to_hex(sha1));
+ htmlf("blob: %s (", oid_to_hex(oid));
cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
rev, path);
if (ctx.cfg.enable_blame) {
size_t count;
};
-static int single_tree_cb(const unsigned char *sha1, struct strbuf *base,
+static int single_tree_cb(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, int stage,
void *cbdata)
{
}
ctx->name = xstrdup(pathname);
- hashcpy(ctx->oid.hash, sha1);
+ oidcpy(&ctx->oid, oid);
strbuf_addf(ctx->path, "/%s", pathname);
return 0;
}
-static void write_tree_link(const unsigned char *sha1, char *name,
+static void write_tree_link(const struct object_id *oid, char *name,
char *rev, struct strbuf *fullpath)
{
size_t initial_length = fullpath->len;
.nr = 0
};
- hashcpy(tree_ctx.oid.hash, sha1);
+ oidcpy(&tree_ctx.oid, oid);
while (tree_ctx.count == 1) {
cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev,
strbuf_setlen(fullpath, initial_length);
}
-static int ls_item(const unsigned char *sha1, struct strbuf *base,
+static int ls_item(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, int stage, void *cbdata)
{
struct walk_tree_context *walk_tree_ctx = cbdata;
ctx.qry.path ? "/" : "", name);
if (!S_ISGITLINK(mode)) {
- type = sha1_object_info(sha1, &size);
+ type = oid_object_info(the_repository, oid, &size);
if (type == OBJ_BAD) {
htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
name,
- sha1_to_hex(sha1));
+ oid_to_hex(oid));
free(name);
return 0;
}
cgit_print_filemode(mode);
html("</td><td>");
if (S_ISGITLINK(mode)) {
- cgit_submodule_link("ls-mod", fullpath.buf, sha1_to_hex(sha1));
+ cgit_submodule_link("ls-mod", fullpath.buf, oid_to_hex(oid));
} else if (S_ISDIR(mode)) {
- write_tree_link(sha1, name, walk_tree_ctx->curr_rev,
+ write_tree_link(oid, name, walk_tree_ctx->curr_rev,
&fullpath);
} else {
char *ext = strrchr(name, '.');
tree = parse_tree_indirect(oid);
if (!tree) {
cgit_print_error_page(404, "Not found",
- "Not a tree object: %s", sha1_to_hex(oid->hash));
+ "Not a tree object: %s", oid_to_hex(oid));
return;
}
}
-static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+static int walk_tree(const struct object_id *oid, struct strbuf *base,
const char *pathname, unsigned mode, int stage, void *cbdata)
{
struct walk_tree_context *walk_tree_ctx = cbdata;
return READ_TREE_RECURSIVE;
} else {
walk_tree_ctx->state = 2;
- print_object(sha1, buffer.buf, pathname, walk_tree_ctx->curr_rev);
+ print_object(oid, buffer.buf, pathname, walk_tree_ctx->curr_rev);
strbuf_release(&buffer);
return 0;
}
}
- ls_item(sha1, base, pathname, mode, stage, walk_tree_ctx);
+ ls_item(oid, base, pathname, mode, stage, walk_tree_ctx);
return 0;
}
walk_tree_ctx.curr_rev = xstrdup(rev);
if (path == NULL) {
- ls_tree(&commit->tree->object.oid, NULL, &walk_tree_ctx);
+ ls_tree(&commit->maybe_tree->object.oid, NULL, &walk_tree_ctx);
goto cleanup;
}
- read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
+ read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx);
if (walk_tree_ctx.state == 1)
ls_tail();
else if (walk_tree_ctx.state == 2)