Commit c08369d7b2d435a4c881c980f9a7192c5f7fc61a

Tracey Emery 2020-01-15T23:08:12

remove log counting, add to TODO

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;