diff options
-rw-r--r-- | Makefile | 2 | ||||
m--------- | git | 0 | ||||
-rw-r--r-- | parsing.c | 2 | ||||
-rw-r--r-- | shared.c | 2 | ||||
-rw-r--r-- | ui-blame.c | 20 | ||||
-rw-r--r-- | ui-blob.c | 24 | ||||
-rw-r--r-- | ui-clone.c | 5 | ||||
-rw-r--r-- | ui-commit.c | 2 | ||||
-rw-r--r-- | ui-diff.c | 8 | ||||
-rw-r--r-- | ui-log.c | 4 | ||||
-rw-r--r-- | ui-plain.c | 28 | ||||
-rw-r--r-- | ui-snapshot.c | 2 | ||||
-rw-r--r-- | ui-tree.c | 42 |
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) | |||
14 | pdfdir = $(docdir) | 14 | pdfdir = $(docdir) |
15 | mandir = $(prefix)/share/man | 15 | mandir = $(prefix)/share/man |
16 | SHA1_HEADER = <openssl/sha.h> | 16 | SHA1_HEADER = <openssl/sha.h> |
17 | GIT_VER = 2.17.1 | 17 | GIT_VER = 2.18.0 |
18 | GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz | 18 | GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz |
19 | INSTALL = install | 19 | INSTALL = install |
20 | COPYTREE = cp -r | 20 | 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) | |||
200 | const char *p; | 200 | const char *p; |
201 | struct taginfo *ret = NULL; | 201 | struct taginfo *ret = NULL; |
202 | 202 | ||
203 | data = read_sha1_file(tag->object.oid.hash, &type, &size); | 203 | data = read_object_file(&tag->object.oid, &type, &size); |
204 | if (!data || type != OBJ_TAG) | 204 | if (!data || type != OBJ_TAG) |
205 | goto cleanup; | 205 | goto cleanup; |
206 | 206 | ||
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) | |||
239 | file->ptr = (char *)""; | 239 | file->ptr = (char *)""; |
240 | file->size = 0; | 240 | file->size = 0; |
241 | } else { | 241 | } else { |
242 | file->ptr = read_sha1_file(oid->hash, &type, | 242 | file->ptr = read_object_file(oid, &type, |
243 | (unsigned long *)&file->size); | 243 | (unsigned long *)&file->size); |
244 | } | 244 | } |
245 | return 1; | 245 | 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) | |||
49 | 49 | ||
50 | char *detail = emit_suspect_detail(suspect); | 50 | char *detail = emit_suspect_detail(suspect); |
51 | html("<span class='sha1'>"); | 51 | html("<span class='sha1'>"); |
52 | cgit_commit_link(find_unique_abbrev(oid->hash, DEFAULT_ABBREV), detail, | 52 | cgit_commit_link(find_unique_abbrev(oid, DEFAULT_ABBREV), detail, |
53 | NULL, ctx.qry.head, oid_to_hex(oid), suspect->path); | 53 | NULL, ctx.qry.head, oid_to_hex(oid), suspect->path); |
54 | html("</span>"); | 54 | html("</span>"); |
55 | free(detail); | 55 | free(detail); |
@@ -98,7 +98,7 @@ struct walk_tree_context { | |||
98 | int state; | 98 | int state; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | static void print_object(const unsigned char *sha1, const char *path, | 101 | static void print_object(const struct object_id *oid, const char *path, |
102 | const char *basename, const char *rev) | 102 | const char *basename, const char *rev) |
103 | { | 103 | { |
104 | enum object_type type; | 104 | enum object_type type; |
@@ -110,17 +110,17 @@ static void print_object(const unsigned char *sha1, const char *path, | |||
110 | struct blame_origin *o; | 110 | struct blame_origin *o; |
111 | struct blame_entry *ent = NULL; | 111 | struct blame_entry *ent = NULL; |
112 | 112 | ||
113 | type = sha1_object_info(sha1, &size); | 113 | type = oid_object_info(the_repository, oid, &size); |
114 | if (type == OBJ_BAD) { | 114 | if (type == OBJ_BAD) { |
115 | cgit_print_error_page(404, "Not found", "Bad object name: %s", | 115 | cgit_print_error_page(404, "Not found", "Bad object name: %s", |
116 | sha1_to_hex(sha1)); | 116 | oid_to_hex(oid)); |
117 | return; | 117 | return; |
118 | } | 118 | } |
119 | 119 | ||
120 | buf = read_sha1_file(sha1, &type, &size); | 120 | buf = read_object_file(oid, &type, &size); |
121 | if (!buf) { | 121 | if (!buf) { |
122 | cgit_print_error_page(500, "Internal server error", | 122 | cgit_print_error_page(500, "Internal server error", |
123 | "Error reading object %s", sha1_to_hex(sha1)); | 123 | "Error reading object %s", oid_to_hex(oid)); |
124 | return; | 124 | return; |
125 | } | 125 | } |
126 | 126 | ||
@@ -144,7 +144,7 @@ static void print_object(const unsigned char *sha1, const char *path, | |||
144 | cgit_set_title_from_path(path); | 144 | cgit_set_title_from_path(path); |
145 | 145 | ||
146 | cgit_print_layout_start(); | 146 | cgit_print_layout_start(); |
147 | htmlf("blob: %s (", sha1_to_hex(sha1)); | 147 | htmlf("blob: %s (", oid_to_hex(oid)); |
148 | cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); | 148 | cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); |
149 | html(") ("); | 149 | html(") ("); |
150 | cgit_tree_link("tree", NULL, NULL, ctx.qry.head, rev, path); | 150 | cgit_tree_link("tree", NULL, NULL, ctx.qry.head, rev, path); |
@@ -218,7 +218,7 @@ cleanup: | |||
218 | free(buf); | 218 | free(buf); |
219 | } | 219 | } |
220 | 220 | ||
221 | static int walk_tree(const unsigned char *sha1, struct strbuf *base, | 221 | static int walk_tree(const struct object_id *oid, struct strbuf *base, |
222 | const char *pathname, unsigned mode, int stage, | 222 | const char *pathname, unsigned mode, int stage, |
223 | void *cbdata) | 223 | void *cbdata) |
224 | { | 224 | { |
@@ -229,7 +229,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base, | |||
229 | struct strbuf buffer = STRBUF_INIT; | 229 | struct strbuf buffer = STRBUF_INIT; |
230 | strbuf_addbuf(&buffer, base); | 230 | strbuf_addbuf(&buffer, base); |
231 | strbuf_addstr(&buffer, pathname); | 231 | strbuf_addstr(&buffer, pathname); |
232 | print_object(sha1, buffer.buf, pathname, | 232 | print_object(oid, buffer.buf, pathname, |
233 | walk_tree_ctx->curr_rev); | 233 | walk_tree_ctx->curr_rev); |
234 | strbuf_release(&buffer); | 234 | strbuf_release(&buffer); |
235 | walk_tree_ctx->state = 1; | 235 | walk_tree_ctx->state = 1; |
@@ -289,7 +289,7 @@ void cgit_print_blame(void) | |||
289 | walk_tree_ctx.match_baselen = (path_items.match) ? | 289 | walk_tree_ctx.match_baselen = (path_items.match) ? |
290 | basedir_len(path_items.match) : -1; | 290 | basedir_len(path_items.match) : -1; |
291 | 291 | ||
292 | read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, | 292 | read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, |
293 | &walk_tree_ctx); | 293 | &walk_tree_ctx); |
294 | if (!walk_tree_ctx.state) | 294 | if (!walk_tree_ctx.state) |
295 | cgit_print_error_page(404, "Not found", "Not found"); | 295 | 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 { | |||
18 | unsigned int file_only:1; | 18 | unsigned int file_only:1; |
19 | }; | 19 | }; |
20 | 20 | ||
21 | static int walk_tree(const unsigned char *sha1, struct strbuf *base, | 21 | static int walk_tree(const struct object_id *oid, struct strbuf *base, |
22 | const char *pathname, unsigned mode, int stage, void *cbdata) | 22 | const char *pathname, unsigned mode, int stage, void *cbdata) |
23 | { | 23 | { |
24 | struct walk_tree_context *walk_tree_ctx = cbdata; | 24 | struct walk_tree_context *walk_tree_ctx = cbdata; |
@@ -28,7 +28,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base, | |||
28 | if (strncmp(base->buf, walk_tree_ctx->match_path, base->len) | 28 | if (strncmp(base->buf, walk_tree_ctx->match_path, base->len) |
29 | || strcmp(walk_tree_ctx->match_path + base->len, pathname)) | 29 | || strcmp(walk_tree_ctx->match_path + base->len, pathname)) |
30 | return READ_TREE_RECURSIVE; | 30 | return READ_TREE_RECURSIVE; |
31 | hashcpy(walk_tree_ctx->matched_oid->hash, sha1); | 31 | oidcpy(walk_tree_ctx->matched_oid, oid); |
32 | walk_tree_ctx->found_path = 1; | 32 | walk_tree_ctx->found_path = 1; |
33 | return 0; | 33 | return 0; |
34 | } | 34 | } |
@@ -54,9 +54,9 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) | |||
54 | 54 | ||
55 | if (get_oid(ref, &oid)) | 55 | if (get_oid(ref, &oid)) |
56 | goto done; | 56 | goto done; |
57 | if (sha1_object_info(oid.hash, &size) != OBJ_COMMIT) | 57 | if (oid_object_info(the_repository, &oid, &size) != OBJ_COMMIT) |
58 | goto done; | 58 | goto done; |
59 | read_tree_recursive(lookup_commit_reference(&oid)->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); | 59 | read_tree_recursive(lookup_commit_reference(&oid)->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); |
60 | 60 | ||
61 | done: | 61 | done: |
62 | free(path_items.match); | 62 | free(path_items.match); |
@@ -87,17 +87,17 @@ int cgit_print_file(char *path, const char *head, int file_only) | |||
87 | 87 | ||
88 | if (get_oid(head, &oid)) | 88 | if (get_oid(head, &oid)) |
89 | return -1; | 89 | return -1; |
90 | type = sha1_object_info(oid.hash, &size); | 90 | type = oid_object_info(the_repository, &oid, &size); |
91 | if (type == OBJ_COMMIT) { | 91 | if (type == OBJ_COMMIT) { |
92 | commit = lookup_commit_reference(&oid); | 92 | commit = lookup_commit_reference(&oid); |
93 | read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); | 93 | read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); |
94 | if (!walk_tree_ctx.found_path) | 94 | if (!walk_tree_ctx.found_path) |
95 | return -1; | 95 | return -1; |
96 | type = sha1_object_info(oid.hash, &size); | 96 | type = oid_object_info(the_repository, &oid, &size); |
97 | } | 97 | } |
98 | if (type == OBJ_BAD) | 98 | if (type == OBJ_BAD) |
99 | return -1; | 99 | return -1; |
100 | buf = read_sha1_file(oid.hash, &type, &size); | 100 | buf = read_object_file(&oid, &type, &size); |
101 | if (!buf) | 101 | if (!buf) |
102 | return -1; | 102 | return -1; |
103 | buf[size] = '\0'; | 103 | buf[size] = '\0'; |
@@ -142,12 +142,12 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl | |||
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | type = sha1_object_info(oid.hash, &size); | 145 | type = oid_object_info(the_repository, &oid, &size); |
146 | 146 | ||
147 | if ((!hex) && type == OBJ_COMMIT && path) { | 147 | if ((!hex) && type == OBJ_COMMIT && path) { |
148 | commit = lookup_commit_reference(&oid); | 148 | commit = lookup_commit_reference(&oid); |
149 | read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); | 149 | read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); |
150 | type = sha1_object_info(oid.hash, &size); | 150 | type = oid_object_info(the_repository, &oid, &size); |
151 | } | 151 | } |
152 | 152 | ||
153 | if (type == OBJ_BAD) { | 153 | if (type == OBJ_BAD) { |
@@ -156,7 +156,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl | |||
156 | return; | 156 | return; |
157 | } | 157 | } |
158 | 158 | ||
159 | buf = read_sha1_file(oid.hash, &type, &size); | 159 | buf = read_object_file(&oid, &type, &size); |
160 | if (!buf) { | 160 | if (!buf) { |
161 | cgit_print_error_page(500, "Internal server error", | 161 | cgit_print_error_page(500, "Internal server error", |
162 | "Error reading object %s", hex); | 162 | "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 @@ | |||
12 | #include "html.h" | 12 | #include "html.h" |
13 | #include "ui-shared.h" | 13 | #include "ui-shared.h" |
14 | #include "packfile.h" | 14 | #include "packfile.h" |
15 | #include "object-store.h" | ||
15 | 16 | ||
16 | static int print_ref_info(const char *refname, const struct object_id *oid, | 17 | static int print_ref_info(const char *refname, const struct object_id *oid, |
17 | int flags, void *cb_data) | 18 | int flags, void *cb_data) |
@@ -38,8 +39,8 @@ static void print_pack_info(void) | |||
38 | ctx.page.mimetype = "text/plain"; | 39 | ctx.page.mimetype = "text/plain"; |
39 | ctx.page.filename = "objects/info/packs"; | 40 | ctx.page.filename = "objects/info/packs"; |
40 | cgit_print_http_headers(); | 41 | cgit_print_http_headers(); |
41 | prepare_packed_git(); | 42 | reprepare_packed_git(the_repository); |
42 | for (pack = packed_git; pack; pack = pack->next) { | 43 | for (pack = get_packed_git(the_repository); pack; pack = pack->next) { |
43 | if (pack->pack_local) { | 44 | if (pack->pack_local) { |
44 | offset = strrchr(pack->pack_name, '/'); | 45 | offset = strrchr(pack->pack_name, '/'); |
45 | if (offset && offset[1] != '\0') | 46 | 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) | |||
78 | html(")</td></tr>\n"); | 78 | html(")</td></tr>\n"); |
79 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); | 79 | html("<tr><th>tree</th><td colspan='2' class='sha1'>"); |
80 | tmp = xstrdup(hex); | 80 | tmp = xstrdup(hex); |
81 | cgit_tree_link(oid_to_hex(&commit->tree->object.oid), NULL, NULL, | 81 | cgit_tree_link(oid_to_hex(&commit->maybe_tree->object.oid), NULL, NULL, |
82 | ctx.qry.head, tmp, NULL); | 82 | ctx.qry.head, tmp, NULL); |
83 | if (prefix) { | 83 | if (prefix) { |
84 | html(" /"); | 84 | 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, | |||
258 | htmlf("<br/>deleted file mode %.6o", mode1); | 258 | htmlf("<br/>deleted file mode %.6o", mode1); |
259 | 259 | ||
260 | if (!subproject) { | 260 | if (!subproject) { |
261 | abbrev1 = xstrdup(find_unique_abbrev(oid1->hash, DEFAULT_ABBREV)); | 261 | abbrev1 = xstrdup(find_unique_abbrev(oid1, DEFAULT_ABBREV)); |
262 | abbrev2 = xstrdup(find_unique_abbrev(oid2->hash, DEFAULT_ABBREV)); | 262 | abbrev2 = xstrdup(find_unique_abbrev(oid2, DEFAULT_ABBREV)); |
263 | htmlf("<br/>index %s..%s", abbrev1, abbrev2); | 263 | htmlf("<br/>index %s..%s", abbrev1, abbrev2); |
264 | free(abbrev1); | 264 | free(abbrev1); |
265 | free(abbrev2); | 265 | free(abbrev2); |
@@ -413,7 +413,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, | |||
413 | "Bad commit: %s", oid_to_hex(new_rev_oid)); | 413 | "Bad commit: %s", oid_to_hex(new_rev_oid)); |
414 | return; | 414 | return; |
415 | } | 415 | } |
416 | new_tree_oid = &commit->tree->object.oid; | 416 | new_tree_oid = &commit->maybe_tree->object.oid; |
417 | 417 | ||
418 | if (old_rev) { | 418 | if (old_rev) { |
419 | if (get_oid(old_rev, old_rev_oid)) { | 419 | if (get_oid(old_rev, old_rev_oid)) { |
@@ -434,7 +434,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, | |||
434 | "Bad commit: %s", oid_to_hex(old_rev_oid)); | 434 | "Bad commit: %s", oid_to_hex(old_rev_oid)); |
435 | return; | 435 | return; |
436 | } | 436 | } |
437 | old_tree_oid = &commit2->tree->object.oid; | 437 | old_tree_oid = &commit2->maybe_tree->object.oid; |
438 | } else { | 438 | } else { |
439 | old_tree_oid = NULL; | 439 | old_tree_oid = NULL; |
440 | } | 440 | } |
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) | |||
153 | rem_lines = 0; | 153 | rem_lines = 0; |
154 | 154 | ||
155 | revs->diffopt.flags.recursive = 1; | 155 | revs->diffopt.flags.recursive = 1; |
156 | diff_tree_oid(&parent->tree->object.oid, | 156 | diff_tree_oid(&parent->maybe_tree->object.oid, |
157 | &commit->tree->object.oid, | 157 | &commit->maybe_tree->object.oid, |
158 | "", &revs->diffopt); | 158 | "", &revs->diffopt); |
159 | diffcore_std(&revs->diffopt); | 159 | diffcore_std(&revs->diffopt); |
160 | 160 | ||
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 { | |||
16 | int match; | 16 | int match; |
17 | }; | 17 | }; |
18 | 18 | ||
19 | static int print_object(const unsigned char *sha1, const char *path) | 19 | static int print_object(const struct object_id *oid, const char *path) |
20 | { | 20 | { |
21 | enum object_type type; | 21 | enum object_type type; |
22 | char *buf, *mimetype; | 22 | char *buf, *mimetype; |
23 | unsigned long size; | 23 | unsigned long size; |
24 | 24 | ||
25 | type = sha1_object_info(sha1, &size); | 25 | type = oid_object_info(the_repository, oid, &size); |
26 | if (type == OBJ_BAD) { | 26 | if (type == OBJ_BAD) { |
27 | cgit_print_error_page(404, "Not found", "Not found"); | 27 | cgit_print_error_page(404, "Not found", "Not found"); |
28 | return 0; | 28 | return 0; |
29 | } | 29 | } |
30 | 30 | ||
31 | buf = read_sha1_file(sha1, &type, &size); | 31 | buf = read_object_file(oid, &type, &size); |
32 | if (!buf) { | 32 | if (!buf) { |
33 | cgit_print_error_page(404, "Not found", "Not found"); | 33 | cgit_print_error_page(404, "Not found", "Not found"); |
34 | return 0; | 34 | return 0; |
@@ -57,7 +57,7 @@ static int print_object(const unsigned char *sha1, const char *path) | |||
57 | } | 57 | } |
58 | ctx.page.filename = path; | 58 | ctx.page.filename = path; |
59 | ctx.page.size = size; | 59 | ctx.page.size = size; |
60 | ctx.page.etag = sha1_to_hex(sha1); | 60 | ctx.page.etag = oid_to_hex(oid); |
61 | cgit_print_http_headers(); | 61 | cgit_print_http_headers(); |
62 | html_raw(buf, size); | 62 | html_raw(buf, size); |
63 | free(mimetype); | 63 | free(mimetype); |
@@ -73,7 +73,7 @@ static char *buildpath(const char *base, int baselen, const char *path) | |||
73 | return fmtalloc("%.*s/", baselen, base); | 73 | return fmtalloc("%.*s/", baselen, base); |
74 | } | 74 | } |
75 | 75 | ||
76 | static void print_dir(const unsigned char *sha1, const char *base, | 76 | static void print_dir(const struct object_id *oid, const char *base, |
77 | int baselen, const char *path) | 77 | int baselen, const char *path) |
78 | { | 78 | { |
79 | char *fullpath, *slash; | 79 | char *fullpath, *slash; |
@@ -81,7 +81,7 @@ static void print_dir(const unsigned char *sha1, const char *base, | |||
81 | 81 | ||
82 | fullpath = buildpath(base, baselen, path); | 82 | fullpath = buildpath(base, baselen, path); |
83 | slash = (fullpath[0] == '/' ? "" : "/"); | 83 | slash = (fullpath[0] == '/' ? "" : "/"); |
84 | ctx.page.etag = sha1_to_hex(sha1); | 84 | ctx.page.etag = oid_to_hex(oid); |
85 | cgit_print_http_headers(); | 85 | cgit_print_http_headers(); |
86 | htmlf("<html><head><title>%s", slash); | 86 | htmlf("<html><head><title>%s", slash); |
87 | html_txt(fullpath); | 87 | html_txt(fullpath); |
@@ -106,7 +106,7 @@ static void print_dir(const unsigned char *sha1, const char *base, | |||
106 | free(fullpath); | 106 | free(fullpath); |
107 | } | 107 | } |
108 | 108 | ||
109 | static void print_dir_entry(const unsigned char *sha1, const char *base, | 109 | static void print_dir_entry(const struct object_id *oid, const char *base, |
110 | int baselen, const char *path, unsigned mode) | 110 | int baselen, const char *path, unsigned mode) |
111 | { | 111 | { |
112 | char *fullpath; | 112 | char *fullpath; |
@@ -116,7 +116,7 @@ static void print_dir_entry(const unsigned char *sha1, const char *base, | |||
116 | fullpath[strlen(fullpath) - 1] = 0; | 116 | fullpath[strlen(fullpath) - 1] = 0; |
117 | html(" <li>"); | 117 | html(" <li>"); |
118 | if (S_ISGITLINK(mode)) { | 118 | if (S_ISGITLINK(mode)) { |
119 | cgit_submodule_link(NULL, fullpath, sha1_to_hex(sha1)); | 119 | cgit_submodule_link(NULL, fullpath, oid_to_hex(oid)); |
120 | } else | 120 | } else |
121 | cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, | 121 | cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, |
122 | fullpath); | 122 | fullpath); |
@@ -129,22 +129,22 @@ static void print_dir_tail(void) | |||
129 | html(" </ul>\n</body></html>\n"); | 129 | html(" </ul>\n</body></html>\n"); |
130 | } | 130 | } |
131 | 131 | ||
132 | static int walk_tree(const unsigned char *sha1, struct strbuf *base, | 132 | static int walk_tree(const struct object_id *oid, struct strbuf *base, |
133 | const char *pathname, unsigned mode, int stage, void *cbdata) | 133 | const char *pathname, unsigned mode, int stage, void *cbdata) |
134 | { | 134 | { |
135 | struct walk_tree_context *walk_tree_ctx = cbdata; | 135 | struct walk_tree_context *walk_tree_ctx = cbdata; |
136 | 136 | ||
137 | if (base->len == walk_tree_ctx->match_baselen) { | 137 | if (base->len == walk_tree_ctx->match_baselen) { |
138 | if (S_ISREG(mode) || S_ISLNK(mode)) { | 138 | if (S_ISREG(mode) || S_ISLNK(mode)) { |
139 | if (print_object(sha1, pathname)) | 139 | if (print_object(oid, pathname)) |
140 | walk_tree_ctx->match = 1; | 140 | walk_tree_ctx->match = 1; |
141 | } else if (S_ISDIR(mode)) { | 141 | } else if (S_ISDIR(mode)) { |
142 | print_dir(sha1, base->buf, base->len, pathname); | 142 | print_dir(oid, base->buf, base->len, pathname); |
143 | walk_tree_ctx->match = 2; | 143 | walk_tree_ctx->match = 2; |
144 | return READ_TREE_RECURSIVE; | 144 | return READ_TREE_RECURSIVE; |
145 | } | 145 | } |
146 | } else if (base->len < INT_MAX && (int)base->len > walk_tree_ctx->match_baselen) { | 146 | } else if (base->len < INT_MAX && (int)base->len > walk_tree_ctx->match_baselen) { |
147 | print_dir_entry(sha1, base->buf, base->len, pathname, mode); | 147 | print_dir_entry(oid, base->buf, base->len, pathname, mode); |
148 | walk_tree_ctx->match = 2; | 148 | walk_tree_ctx->match = 2; |
149 | } else if (S_ISDIR(mode)) { | 149 | } else if (S_ISDIR(mode)) { |
150 | return READ_TREE_RECURSIVE; | 150 | return READ_TREE_RECURSIVE; |
@@ -193,12 +193,12 @@ void cgit_print_plain(void) | |||
193 | if (!path_items.match) { | 193 | if (!path_items.match) { |
194 | path_items.match = ""; | 194 | path_items.match = ""; |
195 | walk_tree_ctx.match_baselen = -1; | 195 | walk_tree_ctx.match_baselen = -1; |
196 | print_dir(commit->tree->object.oid.hash, "", 0, ""); | 196 | print_dir(&commit->maybe_tree->object.oid, "", 0, ""); |
197 | walk_tree_ctx.match = 2; | 197 | walk_tree_ctx.match = 2; |
198 | } | 198 | } |
199 | else | 199 | else |
200 | walk_tree_ctx.match_baselen = basedir_len(path_items.match); | 200 | walk_tree_ctx.match_baselen = basedir_len(path_items.match); |
201 | read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); | 201 | read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); |
202 | if (!walk_tree_ctx.match) | 202 | if (!walk_tree_ctx.match) |
203 | cgit_print_error_page(404, "Not found", "Not found"); | 203 | cgit_print_error_page(404, "Not found", "Not found"); |
204 | else if (walk_tree_ctx.match == 2) | 204 | 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, | |||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | 176 | ||
177 | buf = read_sha1_file(note->hash, &type, &size); | 177 | buf = read_object_file(note, &type, &size); |
178 | if (!buf) { | 178 | if (!buf) { |
179 | cgit_print_error_page(404, "Not found", "Not found"); | 179 | cgit_print_error_page(404, "Not found", "Not found"); |
180 | return 0; | 180 | 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) | |||
84 | html("</table>\n"); | 84 | html("</table>\n"); |
85 | } | 85 | } |
86 | 86 | ||
87 | static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev) | 87 | static void print_object(const struct object_id *oid, char *path, const char *basename, const char *rev) |
88 | { | 88 | { |
89 | enum object_type type; | 89 | enum object_type type; |
90 | char *buf; | 90 | char *buf; |
91 | unsigned long size; | 91 | unsigned long size; |
92 | 92 | ||
93 | type = sha1_object_info(sha1, &size); | 93 | type = oid_object_info(the_repository, oid, &size); |
94 | if (type == OBJ_BAD) { | 94 | if (type == OBJ_BAD) { |
95 | cgit_print_error_page(404, "Not found", | 95 | cgit_print_error_page(404, "Not found", |
96 | "Bad object name: %s", sha1_to_hex(sha1)); | 96 | "Bad object name: %s", oid_to_hex(oid)); |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | 99 | ||
100 | buf = read_sha1_file(sha1, &type, &size); | 100 | buf = read_object_file(oid, &type, &size); |
101 | if (!buf) { | 101 | if (!buf) { |
102 | cgit_print_error_page(500, "Internal server error", | 102 | cgit_print_error_page(500, "Internal server error", |
103 | "Error reading object %s", sha1_to_hex(sha1)); | 103 | "Error reading object %s", oid_to_hex(oid)); |
104 | return; | 104 | return; |
105 | } | 105 | } |
106 | 106 | ||
107 | cgit_set_title_from_path(path); | 107 | cgit_set_title_from_path(path); |
108 | 108 | ||
109 | cgit_print_layout_start(); | 109 | cgit_print_layout_start(); |
110 | htmlf("blob: %s (", sha1_to_hex(sha1)); | 110 | htmlf("blob: %s (", oid_to_hex(oid)); |
111 | cgit_plain_link("plain", NULL, NULL, ctx.qry.head, | 111 | cgit_plain_link("plain", NULL, NULL, ctx.qry.head, |
112 | rev, path); | 112 | rev, path); |
113 | if (ctx.cfg.enable_blame) { | 113 | if (ctx.cfg.enable_blame) { |
@@ -138,7 +138,7 @@ struct single_tree_ctx { | |||
138 | size_t count; | 138 | size_t count; |
139 | }; | 139 | }; |
140 | 140 | ||
141 | static int single_tree_cb(const unsigned char *sha1, struct strbuf *base, | 141 | static int single_tree_cb(const struct object_id *oid, struct strbuf *base, |
142 | const char *pathname, unsigned mode, int stage, | 142 | const char *pathname, unsigned mode, int stage, |
143 | void *cbdata) | 143 | void *cbdata) |
144 | { | 144 | { |
@@ -153,12 +153,12 @@ static int single_tree_cb(const unsigned char *sha1, struct strbuf *base, | |||
153 | } | 153 | } |
154 | 154 | ||
155 | ctx->name = xstrdup(pathname); | 155 | ctx->name = xstrdup(pathname); |
156 | hashcpy(ctx->oid.hash, sha1); | 156 | oidcpy(&ctx->oid, oid); |
157 | strbuf_addf(ctx->path, "/%s", pathname); | 157 | strbuf_addf(ctx->path, "/%s", pathname); |
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | static void write_tree_link(const unsigned char *sha1, char *name, | 161 | static void write_tree_link(const struct object_id *oid, char *name, |
162 | char *rev, struct strbuf *fullpath) | 162 | char *rev, struct strbuf *fullpath) |
163 | { | 163 | { |
164 | size_t initial_length = fullpath->len; | 164 | size_t initial_length = fullpath->len; |
@@ -171,7 +171,7 @@ static void write_tree_link(const unsigned char *sha1, char *name, | |||
171 | .nr = 0 | 171 | .nr = 0 |
172 | }; | 172 | }; |
173 | 173 | ||
174 | hashcpy(tree_ctx.oid.hash, sha1); | 174 | oidcpy(&tree_ctx.oid, oid); |
175 | 175 | ||
176 | while (tree_ctx.count == 1) { | 176 | while (tree_ctx.count == 1) { |
177 | cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev, | 177 | 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, | |||
198 | strbuf_setlen(fullpath, initial_length); | 198 | strbuf_setlen(fullpath, initial_length); |
199 | } | 199 | } |
200 | 200 | ||
201 | static int ls_item(const unsigned char *sha1, struct strbuf *base, | 201 | static int ls_item(const struct object_id *oid, struct strbuf *base, |
202 | const char *pathname, unsigned mode, int stage, void *cbdata) | 202 | const char *pathname, unsigned mode, int stage, void *cbdata) |
203 | { | 203 | { |
204 | struct walk_tree_context *walk_tree_ctx = cbdata; | 204 | struct walk_tree_context *walk_tree_ctx = cbdata; |
@@ -213,11 +213,11 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base, | |||
213 | ctx.qry.path ? "/" : "", name); | 213 | ctx.qry.path ? "/" : "", name); |
214 | 214 | ||
215 | if (!S_ISGITLINK(mode)) { | 215 | if (!S_ISGITLINK(mode)) { |
216 | type = sha1_object_info(sha1, &size); | 216 | type = oid_object_info(the_repository, oid, &size); |
217 | if (type == OBJ_BAD) { | 217 | if (type == OBJ_BAD) { |
218 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", | 218 | htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", |
219 | name, | 219 | name, |
220 | sha1_to_hex(sha1)); | 220 | oid_to_hex(oid)); |
221 | free(name); | 221 | free(name); |
222 | return 0; | 222 | return 0; |
223 | } | 223 | } |
@@ -227,9 +227,9 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base, | |||
227 | cgit_print_filemode(mode); | 227 | cgit_print_filemode(mode); |
228 | html("</td><td>"); | 228 | html("</td><td>"); |
229 | if (S_ISGITLINK(mode)) { | 229 | if (S_ISGITLINK(mode)) { |
230 | cgit_submodule_link("ls-mod", fullpath.buf, sha1_to_hex(sha1)); | 230 | cgit_submodule_link("ls-mod", fullpath.buf, oid_to_hex(oid)); |
231 | } else if (S_ISDIR(mode)) { | 231 | } else if (S_ISDIR(mode)) { |
232 | write_tree_link(sha1, name, walk_tree_ctx->curr_rev, | 232 | write_tree_link(oid, name, walk_tree_ctx->curr_rev, |
233 | &fullpath); | 233 | &fullpath); |
234 | } else { | 234 | } else { |
235 | char *ext = strrchr(name, '.'); | 235 | char *ext = strrchr(name, '.'); |
@@ -289,7 +289,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co | |||
289 | tree = parse_tree_indirect(oid); | 289 | tree = parse_tree_indirect(oid); |
290 | if (!tree) { | 290 | if (!tree) { |
291 | cgit_print_error_page(404, "Not found", | 291 | cgit_print_error_page(404, "Not found", |
292 | "Not a tree object: %s", sha1_to_hex(oid->hash)); | 292 | "Not a tree object: %s", oid_to_hex(oid)); |
293 | return; | 293 | return; |
294 | } | 294 | } |
295 | 295 | ||
@@ -299,7 +299,7 @@ static void ls_tree(const struct object_id *oid, char *path, struct walk_tree_co | |||
299 | } | 299 | } |
300 | 300 | ||
301 | 301 | ||
302 | static int walk_tree(const unsigned char *sha1, struct strbuf *base, | 302 | static int walk_tree(const struct object_id *oid, struct strbuf *base, |
303 | const char *pathname, unsigned mode, int stage, void *cbdata) | 303 | const char *pathname, unsigned mode, int stage, void *cbdata) |
304 | { | 304 | { |
305 | struct walk_tree_context *walk_tree_ctx = cbdata; | 305 | struct walk_tree_context *walk_tree_ctx = cbdata; |
@@ -320,12 +320,12 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base, | |||
320 | return READ_TREE_RECURSIVE; | 320 | return READ_TREE_RECURSIVE; |
321 | } else { | 321 | } else { |
322 | walk_tree_ctx->state = 2; | 322 | walk_tree_ctx->state = 2; |
323 | print_object(sha1, buffer.buf, pathname, walk_tree_ctx->curr_rev); | 323 | print_object(oid, buffer.buf, pathname, walk_tree_ctx->curr_rev); |
324 | strbuf_release(&buffer); | 324 | strbuf_release(&buffer); |
325 | return 0; | 325 | return 0; |
326 | } | 326 | } |
327 | } | 327 | } |
328 | ls_item(sha1, base, pathname, mode, stage, walk_tree_ctx); | 328 | ls_item(oid, base, pathname, mode, stage, walk_tree_ctx); |
329 | return 0; | 329 | return 0; |
330 | } | 330 | } |
331 | 331 | ||
@@ -369,11 +369,11 @@ void cgit_print_tree(const char *rev, char *path) | |||
369 | walk_tree_ctx.curr_rev = xstrdup(rev); | 369 | walk_tree_ctx.curr_rev = xstrdup(rev); |
370 | 370 | ||
371 | if (path == NULL) { | 371 | if (path == NULL) { |
372 | ls_tree(&commit->tree->object.oid, NULL, &walk_tree_ctx); | 372 | ls_tree(&commit->maybe_tree->object.oid, NULL, &walk_tree_ctx); |
373 | goto cleanup; | 373 | goto cleanup; |
374 | } | 374 | } |
375 | 375 | ||
376 | read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); | 376 | read_tree_recursive(commit->maybe_tree, "", 0, 0, &paths, walk_tree, &walk_tree_ctx); |
377 | if (walk_tree_ctx.state == 1) | 377 | if (walk_tree_ctx.state == 1) |
378 | ls_tail(); | 378 | ls_tail(); |
379 | else if (walk_tree_ctx.state == 2) | 379 | else if (walk_tree_ctx.state == 2) |