remove log counting, add to TODO
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
diff --git a/Makefile b/Makefile
index 485f779..4c9c3d5 100644
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,9 @@ SUBDIR = libexec got tog
.if make(regress) || make(obj) || make(clean) || make(release)
SUBDIR += regress
-# not part of original SUBDIR, since we don't build gotweb by default and
-# the port will be split into sub packages
+.endif
+
+.if make(clean)
SUBDIR += gotweb
.endif
diff --git a/gotweb/Makefile b/gotweb/Makefile
index a8779fe..82b776f 100644
--- a/gotweb/Makefile
+++ b/gotweb/Makefile
@@ -32,9 +32,6 @@ realinstall:
fi
${INSTALL} -c -o ${WWWUSR} -g ${WWWGRP} -m 0755 \
files/cgi-bin/gw_tmpl/* ${TMPL_DIR}
- if [ ! -d ${ETC_DIR}/. ]; then \
- ${INSTALL} -d -o root -g daemon -m 755 ${ETC_DIR}; \
- fi
if [ ! -d ${HTTPD_DIR}/. ]; then \
${INSTALL} -d -o root -g daemon -m 755 ${HTTPD_DIR}; \
fi
diff --git a/gotweb/README b/gotweb/README
index af0950e..b91a767 100644
--- a/gotweb/README
+++ b/gotweb/README
@@ -1,4 +1,4 @@
-Game of Trees Web (Gotweb) is a read-only web implementation of Got.
+Game of Trees Web (Gotweb) is a read-only web front-end for Got.
Gotweb is still under development; it is being developed exclusively
on OpenBSD and its target audience are OpenBSD developers. Gotweb is
diff --git a/gotweb/TODO b/gotweb/TODO
index a55dfa2..969f659 100644
--- a/gotweb/TODO
+++ b/gotweb/TODO
@@ -1,7 +1,4 @@
-Complete templates.
-Complete stylesheets.
-Complete gw_funcs
-----
+TODO
- Add Prev/Next to shortlogs/logs that have more entries than
got_max_commits_display
@@ -14,3 +11,5 @@ Complete gw_funcs
- Redo index header, so columns are removed when content is set to not display
in gotweb.conf.
+
+- Move pledge to each function. Only diffing needs wpath and cpath.
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index c7b010c..daa235b 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -145,9 +145,6 @@ static const struct kvalid gw_keys[KEY__ZMAX] = {
{ kvalid_stringne, "path" },
};
-int gw_get_repo_log_count(struct gw_trans *,
- char *);
-
static struct gw_dir *gw_init_gw_dir(char *);
static char *gw_get_repo_description(struct gw_trans *,
@@ -263,145 +260,6 @@ gw_apply_unveil(const char *repo_path, const char *repo_file)
return NULL;
}
-int
-gw_get_repo_log_count(struct gw_trans *gw_trans, char *start_commit)
-{
- const struct got_error *error;
- struct got_repository *repo = NULL;
- struct got_reflist_head refs;
- struct got_commit_object *commit = NULL;
- struct got_object_id *id = NULL;
- struct got_commit_graph *graph = NULL;
- char *in_repo_path = NULL, *path = NULL;
- int log_count = 0;
-
- error = got_repo_open(&repo, gw_trans->repo_path, NULL);
- if (error)
- return 0;
-
- SIMPLEQ_INIT(&refs);
-
- if (start_commit == NULL) {
- struct got_reference *head_ref;
- error = got_ref_open(&head_ref, repo, gw_trans->headref, 0);
- if (error)
- goto done;
-
- error = got_ref_resolve(&id, repo, head_ref);
- got_ref_close(head_ref);
- if (error)
- goto done;
-
- error = got_object_open_as_commit(&commit, repo, id);
- } else {
- struct got_reference *ref;
- error = got_ref_open(&ref, repo, start_commit, 0);
- if (error == NULL) {
- int obj_type;
- error = got_ref_resolve(&id, repo, ref);
- got_ref_close(ref);
- if (error)
- goto done;
- error = got_object_get_type(&obj_type, repo, id);
- if (error)
- goto done;
- if (obj_type == GOT_OBJ_TYPE_TAG) {
- struct got_tag_object *tag;
- error = got_object_open_as_tag(&tag, repo, id);
- if (error)
- goto done;
- if (got_object_tag_get_object_type(tag) !=
- GOT_OBJ_TYPE_COMMIT) {
- got_object_tag_close(tag);
- error = got_error(GOT_ERR_OBJ_TYPE);
- goto done;
- }
- free(id);
- id = got_object_id_dup(
- got_object_tag_get_object_id(tag));
- if (id == NULL)
- error = got_error_from_errno(
- "got_object_id_dup");
- got_object_tag_close(tag);
- if (error)
- goto done;
- } else if (obj_type != GOT_OBJ_TYPE_COMMIT) {
- error = got_error(GOT_ERR_OBJ_TYPE);
- goto done;
- }
- error = got_object_open_as_commit(&commit, repo, id);
- if (error)
- goto done;
- }
- if (commit == NULL) {
- error = got_repo_match_object_id_prefix(&id,
- start_commit, GOT_OBJ_TYPE_COMMIT, repo);
- if (error)
- goto done;
- }
- error = got_repo_match_object_id_prefix(&id,
- start_commit, GOT_OBJ_TYPE_COMMIT, repo);
- if (error)
- goto done;
- }
-
- error = got_object_open_as_commit(&commit, repo, id);
- if (error)
- goto done;
-
- error = got_repo_map_path(&in_repo_path, repo, gw_trans->repo_path, 1);
- if (error)
- goto done;
-
- if (in_repo_path) {
- free(path);
- path = in_repo_path;
- }
-
- error = got_ref_list(&refs, repo, NULL, got_ref_cmp_by_name, NULL);
- if (error)
- goto done;
-
- error = got_commit_graph_open(&graph, path, 0);
- if (error)
- goto done;
-
- error = got_commit_graph_iter_start(graph, id, repo, NULL, NULL);
- if (error)
- goto done;
-
- for (;;) {
- error = got_commit_graph_iter_next(&id, graph, repo, NULL,
- NULL);
- if (error) {
- if (error->code == GOT_ERR_ITER_COMPLETED)
- error = NULL;
- break;
- }
- if (id == NULL)
- break;
-
- if (error)
- break;
- log_count++;
- }
-done:
- free(in_repo_path);
- if (graph)
- got_commit_graph_close(graph);
- if (repo) {
- error = got_repo_close(repo);
- if (error)
- return 0;
- }
- if (error) {
- khttp_puts(gw_trans->gw_req, "Error: ");
- khttp_puts(gw_trans->gw_req, error->msg);
- return 0;
- } else
- return log_count;
-}
-
static const struct got_error *
gw_blame(struct gw_trans *gw_trans)
{
@@ -1482,14 +1340,11 @@ gw_get_repo_log(struct gw_trans *gw_trans, const char *search_pattern,
*log_blame_html = NULL;
char *commit_log0, *newline;
regex_t regex;
- int have_match, log_count = 0, has_parent = 1;
+ int have_match, has_parent = 1;
size_t newsize;
struct buf *diffbuf = NULL;
time_t committer_time;
- if (gw_trans->action == GW_LOG || gw_trans->action == GW_LOGBRIEFS)
- log_count = gw_get_repo_log_count(gw_trans, start_commit);
-
error = buf_alloc(&diffbuf, 0);
if (error)
return NULL;
@@ -2768,7 +2623,7 @@ gw_html_escape(const char *html)
}
int
-main()
+main(int argc, char *argv[])
{
const struct got_error *error = NULL;
struct gw_trans *gw_trans;