aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
m---------git0
-rw-r--r--parsing.c2
-rw-r--r--shared.c2
-rw-r--r--ui-blame.c20
-rw-r--r--ui-blob.c24
-rw-r--r--ui-clone.c5
-rw-r--r--ui-commit.c2
-rw-r--r--ui-diff.c8
-rw-r--r--ui-log.c4
-rw-r--r--ui-plain.c28
-rw-r--r--ui-snapshot.c2
-rw-r--r--ui-tree.c42
13 files changed, 71 insertions, 70 deletions
diff --git a/Makefile b/Makefile
index be2ed4f..137150c 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ htmldir = $(docdir)
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
diff --git a/git b/git
-Subproject fc54c1af3ec09bab8b8ea09768c2da4069b7f53
+Subproject 53f9a3e157dbbc901a02ac2c73346d375e24978
diff --git a/parsing.c b/parsing.c
index fd1ea99..12453c2 100644
--- a/parsing.c
+++ b/parsing.c
@@ -200,7 +200,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag)
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;
diff --git a/shared.c b/shared.c
index d59ae7e..d7c7636 100644
--- a/shared.c
+++ b/shared.c
@@ -239,7 +239,7 @@ static int load_mmfile(mmfile_t *file, const struct object_id *oid)
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;
diff --git a/ui-blame.c b/ui-blame.c
index b118a81..50d0580 100644
--- a/ui-blame.c
+++ b/ui-blame.c
@@ -49,7 +49,7 @@ static void emit_blame_entry_hash(struct blame_entry *ent)
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);
@@ -98,7 +98,7 @@ struct walk_tree_context {
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;
@@ -110,17 +110,17 @@ static void print_object(const unsigned char *sha1, const char *path,
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;
}
@@ -144,7 +144,7 @@ static void print_object(const unsigned char *sha1, const char *path,
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);
@@ -218,7 +218,7 @@ cleanup:
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)
{
@@ -229,7 +229,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
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;
@@ -289,7 +289,7 @@ void cgit_print_blame(void)
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");
diff --git a/ui-blob.c b/ui-blob.c
index 761e886..7b6da2a 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -18,7 +18,7 @@ struct walk_tree_context {
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;
@@ -28,7 +28,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
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;
}
@@ -54,9 +54,9 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only)
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);
@@ -87,17 +87,17 @@ int cgit_print_file(char *path, const char *head, int file_only)
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';
@@ -142,12 +142,12 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
}
}
- 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) {
@@ -156,7 +156,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl
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);
diff --git a/ui-clone.c b/ui-clone.c
index bc98980..2c1ac3d 100644
--- a/ui-clone.c
+++ b/ui-clone.c
@@ -12,6 +12,7 @@
#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)
@@ -38,8 +39,8 @@ static void print_pack_info(void)
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')
diff --git a/ui-commit.c b/ui-commit.c
index 65b4603..995cb93 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -78,7 +78,7 @@ void cgit_print_commit(char *hex, const char *prefix)
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(" /");
diff --git a/ui-diff.c b/ui-diff.c
index a10ce8a..e33e9fb 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -258,8 +258,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->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);
@@ -413,7 +413,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
"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)) {
@@ -434,7 +434,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
"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;
}
diff --git a/ui-log.c b/ui-log.c
index b5cd2f6..d696e20 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -153,8 +153,8 @@ static int show_commit(struct commit *commit, struct rev_info *revs)
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);
diff --git a/ui-plain.c b/ui-plain.c
index cfdbf73..ddb3e48 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -16,19 +16,19 @@ struct walk_tree_context {
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;
@@ -57,7 +57,7 @@ static int print_object(const unsigned char *sha1, const char *path)
}
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);
@@ -73,7 +73,7 @@ static char *buildpath(const char *base, int baselen, const char *path)
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;
@@ -81,7 +81,7 @@ static void print_dir(const unsigned char *sha1, const char *base,
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);
@@ -106,7 +106,7 @@ static void print_dir(const unsigned char *sha1, const char *base,
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;
@@ -116,7 +116,7 @@ static void print_dir_entry(const unsigned char *sha1, const char *base,
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);
@@ -129,22 +129,22 @@ static void print_dir_tail(void)
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;
@@ -193,12 +193,12 @@ void cgit_print_plain(void)
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)
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 83ce6e8..92c3277 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -174,7 +174,7 @@ static int write_sig(const struct cgit_snapshot_format *format,
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;
diff --git a/ui-tree.c b/ui-tree.c
index 524de0f..e6b3074 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -84,30 +84,30 @@ static void print_binary_buffer(char *buf, unsigned long size)
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) {
@@ -138,7 +138,7 @@ struct single_tree_ctx {
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)
{
@@ -153,12 +153,12 @@ static int single_tree_cb(const unsigned char *sha1, struct strbuf *base,
}
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;
@@ -171,7 +171,7 @@ static void write_tree_link(const unsigned char *sha1, char *name,
.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,
@@ -198,7 +198,7 @@ static void write_tree_link(const unsigned char *sha1, char *name,
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;
@@ -213,11 +213,11 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
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;
}
@@ -227,9 +227,9 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
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, '.');
@@ -289,7 +289,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co
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;
}
@@ -299,7 +299,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co
}
-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;
@@ -320,12 +320,12 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base,
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;
}
@@ -369,11 +369,11 @@ void cgit_print_tree(const char *rev, char *path)
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)