aboutsummaryrefslogtreecommitdiffstats
path: root/ui-plain.c
diff options
context:
space:
mode:
authorChristian Hesse2018-06-04 18:49:28 +0200
committerJason A. Donenfeld2018-06-27 18:13:03 +0200
commit255b78ff5291cef79978b025c9872f801de89e23 (patch)
tree7938fdb3af17e39507d282595e1591b0984cc2ec /ui-plain.c
parent54d37dc154f5308459df0a90c81dabd0245b6c17 (diff)
downloadcgit-255b78ff5291cef79978b025c9872f801de89e23.tar.gz
cgit-255b78ff5291cef79978b025c9872f801de89e23.tar.bz2
cgit-255b78ff5291cef79978b025c9872f801de89e23.zip
git: update to v2.18.0
Update to git version v2.18.0. Required changes follow upstream commits: * Convert find_unique_abbrev* to struct object_id (aab9583f7b5ea5463eb3f653a0b4ecac7539dc94) * sha1_file: convert read_sha1_file to struct object_id (b4f5aca40e6f77cbabcbf4ff003c3cf30a1830c8) * sha1_file: convert sha1_object_info* to object_id (abef9020e3df87c441c9a3a95f592fce5fa49bb9) * object-store: move packed_git and packed_git_mru to object store (a80d72db2a73174b3f22142eb2014b33696fd795) * treewide: rename tree to maybe_tree (891435d55da80ca3654b19834481205be6bdfe33) The changed data types required some of our own functions to be converted to struct object_id: ls_item print_dir print_dir_entry print_object single_tree_cb walk_tree write_tree_link And finally we use new upstream functions that were added for struct object_id: hashcpy -> oidcpy sha1_to_hex -> oid_to_hex Signed-off-by: Christian Hesse <mail@eworm.de> Reviewed-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-plain.c')
-rw-r--r--ui-plain.c28
1 files changed, 14 insertions, 14 deletions
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
19static int print_object(const unsigned char *sha1, const char *path) 19static 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
76static void print_dir(const unsigned char *sha1, const char *base, 76static 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
109static void print_dir_entry(const unsigned char *sha1, const char *base, 109static 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
132static int walk_tree(const unsigned char *sha1, struct strbuf *base, 132static 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)