Commit Diff


commit - 6e7d5e742fc400b2e52525cfeb475b7326a52485
commit + 978394e7c1b381b6d87cda75ebfaf507bb01ec64
blob - ca882a110794c4d1ce6ac687786c23d5371cf6aa
blob + b439db1b5f1d1a2a2b6127cd2fdcaf12f7bfd10b
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
@@ -460,11 +460,10 @@ got_get_repo_tags(struct request *c, size_t limit)
 	struct querystring *qs = t->qs;
 	struct repo_dir *repo_dir = t->repo_dir;
 	struct got_tag_object *tag = NULL;
-	struct repo_tag *rt = NULL, *trt = NULL;
 	char *in_repo_path = NULL, *repo_path = NULL, *id_str = NULL;
 	char *tag_commit = NULL, *tag_commit0 = NULL;
 	char *commit_msg = NULL, *commit_msg0 = NULL;
-	int chk_next = 0, chk_multi = 1, commit_found = 0, c_cnt = 0;
+	int chk_next = 0, chk_multi = 1, commit_found = 0;
 
 	TAILQ_INIT(&refs);
 
@@ -478,28 +477,28 @@ got_get_repo_tags(struct request *c, size_t limit)
 	if (qs->commit == NULL && (qs->action == TAGS || qs->action == RSS)) {
 		error = got_ref_open(&ref, repo, qs->headref, 0);
 		if (error)
-			goto err;
+			goto done;
 		error = got_ref_resolve(&id, repo, ref);
 		got_ref_close(ref);
 		if (error)
-			goto err;
+			goto done;
 	} else if (qs->commit == NULL && qs->action == TAG) {
 		error = got_error_msg(GOT_ERR_EOF, "commit id missing");
-		goto err;
+		goto done;
 	} else {
 		error = got_repo_match_object_id_prefix(&id, qs->commit,
 		    GOT_OBJ_TYPE_COMMIT, repo);
 		if (error)
-			goto err;
+			goto done;
 	}
 
 	if (qs->action != SUMMARY && qs->action != TAGS) {
 		error = got_object_open_as_commit(&commit, repo, id);
 		if (error)
-			goto err;
+			goto done;
 		error = got_object_commit_get_logmsg(&commit_msg0, commit);
 		if (error)
-			goto err;
+			goto done;
 		if (commit) {
 			got_object_commit_close(commit);
 			commit = NULL;
@@ -508,12 +507,12 @@ got_get_repo_tags(struct request *c, size_t limit)
 
 	error = got_repo_map_path(&in_repo_path, repo, repo_path);
 	if (error)
-		goto err;
+		goto done;
 
 	error = got_ref_list(&refs, repo, "refs/tags", got_ref_cmp_tags,
 	   repo);
 	if (error)
-		goto err;
+		goto done;
 
 	if (limit == 1)
 		chk_multi = 0;
@@ -526,14 +525,14 @@ got_get_repo_tags(struct request *c, size_t limit)
 		struct repo_tag *new_repo_tag = NULL;
 		error = got_init_repo_tag(&new_repo_tag);
 		if (error)
-			goto err;
+			goto done;
 
 		TAILQ_INSERT_TAIL(&t->repo_tags, new_repo_tag, entry);
 
 		new_repo_tag->tag_name = strdup(got_ref_get_name(re->ref));
 		if (new_repo_tag->tag_name == NULL) {
 			error = got_error_from_errno("strdup");
-			goto err;
+			goto done;
 		}
 
 		free(id);
@@ -560,31 +559,31 @@ got_get_repo_tags(struct request *c, size_t limit)
 			    strdup(got_object_commit_get_committer(commit));
 			if (new_repo_tag->tagger == NULL) {
 				error = got_error_from_errno("strdup");
-				goto err;
+				goto done;
 			}
 			new_repo_tag->tagger_time =
 			    got_object_commit_get_committer_time(commit);
 			error = got_object_id_str(&id_str, id);
 			if (error)
-				goto err;
+				goto done;
 		} else {
 			new_repo_tag->tagger =
 			    strdup(got_object_tag_get_tagger(tag));
 			if (new_repo_tag->tagger == NULL) {
 				error = got_error_from_errno("strdup");
-				goto err;
+				goto done;
 			}
 			new_repo_tag->tagger_time =
 			    got_object_tag_get_tagger_time(tag);
 			error = got_object_id_str(&id_str,
 			    got_object_tag_get_object_id(tag));
 			if (error)
-				goto err;
+				goto done;
 		}
 
 		new_repo_tag->commit_id = strdup(id_str);
 		if (new_repo_tag->commit_id == NULL)
-			goto err;
+			goto done;
 
 		if (commit_found == 0 && qs->commit != NULL &&
 		    strncmp(id_str, qs->commit, strlen(id_str)) != 0)
@@ -600,10 +599,10 @@ got_get_repo_tags(struct request *c, size_t limit)
 		 * commits and summary
 		 */
 		if (chk_next) {
-			t->next_id = strdup(new_repo_tag->commit_id);
-			if (t->next_id == NULL) {
+			t->tags_more_id = strdup(new_repo_tag->commit_id);
+			if (t->tags_more_id == NULL) {
 				error = got_error_from_errno("strdup");
-				goto err;
+				goto done;
 			}
 			if (commit) {
 				got_object_commit_close(commit);
@@ -618,14 +617,14 @@ got_get_repo_tags(struct request *c, size_t limit)
 			error = got_object_commit_get_logmsg(&tag_commit0,
 			    commit);
 			if (error)
-				goto err;
+				goto done;
 			got_object_commit_close(commit);
 			commit = NULL;
 		} else {
 			tag_commit0 = strdup(got_object_tag_get_message(tag));
 			if (tag_commit0 == NULL) {
 				error = got_error_from_errno("strdup");
-				goto err;
+				goto done;
 			}
 		}
 
@@ -636,7 +635,7 @@ got_get_repo_tags(struct request *c, size_t limit)
 		if (new_repo_tag->tag_commit == NULL) {
 			error = got_error_from_errno("strdup");
 			free(tag_commit0);
-			goto err;
+			goto done;
 		}
 		free(tag_commit0);
 
@@ -648,7 +647,7 @@ got_get_repo_tags(struct request *c, size_t limit)
 			new_repo_tag->commit_msg = strdup(commit_msg);
 			if (new_repo_tag->commit_msg == NULL) {
 				error = got_error_from_errno("strdup");
-				goto err;
+				goto done;
 			}
 		}
 
@@ -660,36 +659,6 @@ got_get_repo_tags(struct request *c, size_t limit)
 	}
 
  done:
-	/*
-	 * we have tailq populated, so find previous commit id
-	 * for navigation through briefs and commits
-	 */
-	if (t->tag_count == 0) {
-		TAILQ_FOREACH_SAFE(rt, &t->repo_tags, entry, trt) {
-			TAILQ_REMOVE(&t->repo_tags, rt, entry);
-			gotweb_free_repo_tag(rt);
-		}
-	}
-	if (t->tag_count > 0 && t->prev_id == NULL && qs->commit != NULL) {
-		commit_found = 0;
-		TAILQ_FOREACH_REVERSE(rt, &t->repo_tags, repo_tags_head,
-		    entry) {
-			if (commit_found == 0 && rt->commit_id != NULL &&
-			    strcmp(qs->commit, rt->commit_id) != 0) {
-				continue;
-			} else
-				commit_found = 1;
-			if (c_cnt == srv->max_commits_display ||
-			    rt == TAILQ_FIRST(&t->repo_tags)) {
-				t->prev_id = strdup(rt->commit_id);
-				if (t->prev_id == NULL)
-					error = got_error_from_errno("strdup");
-				break;
-			}
-			c_cnt++;
-		}
-	}
- err:
 	if (commit)
 		got_object_commit_close(commit);
 	if (tag)
blob - 5be3db5287206ce4a8158ab600915a933b3a7cdc
blob + 3f6acc37e4d6b9cf0fa15dc461fb048c50502c88
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
@@ -744,8 +744,7 @@ gotweb_free_transport(struct transport *t)
 	gotweb_free_repo_dir(t->repo_dir);
 	gotweb_free_querystring(t->qs);
 	free(t->more_id);
-	free(t->next_id);
-	free(t->prev_id);
+	free(t->tags_more_id);
 	if (t->blob)
 		got_object_blob_close(t->blob);
 	if (t->fp) {
@@ -767,7 +766,7 @@ gotweb_free_transport(struct transport *t)
 }
 
 void
-gotweb_get_navs(struct request *c, struct gotweb_url *prev, int *have_prev,
+gotweb_index_navs(struct request *c, struct gotweb_url *prev, int *have_prev,
     struct gotweb_url *next, int *have_next)
 {
 	struct transport *t = c->t;
@@ -776,52 +775,23 @@ gotweb_get_navs(struct request *c, struct gotweb_url *
 
 	*have_prev = *have_next = 0;
 
-	switch(qs->action) {
-	case INDEX:
-		if (qs->index_page > 0) {
-			*have_prev = 1;
-			*prev = (struct gotweb_url){
-				.action = -1,
-				.index_page = qs->index_page - 1,
-				.page = -1,
-			};
-		}
-		if (t->next_disp == srv->max_repos_display &&
-		    t->repos_total != (qs->index_page + 1) *
-		    srv->max_repos_display) {
-			*have_next = 1;
-			*next = (struct gotweb_url){
-				.action = -1,
-				.index_page = qs->index_page + 1,
-				.page = -1,
-			};
-		}
-		break;
-	case TAGS:
-		if (t->prev_id && qs->commit != NULL &&
-		    strcmp(qs->commit, t->prev_id) != 0) {
-			*have_prev = 1;
-			*prev = (struct gotweb_url){
-				.action = TAGS,
-				.index_page = -1,
-				.page = qs->page - 1,
-				.path = qs->path,
-				.commit = t->prev_id,
-				.headref = qs->headref,
-			};
-		}
-		if (t->next_id) {
-			*have_next = 1;
-			*next = (struct gotweb_url){
-				.action = TAGS,
-				.index_page = -1,
-				.page = qs->page + 1,
-				.path = qs->path,
-				.commit = t->next_id,
-				.headref = qs->headref,
-			};
-		}
-		break;
+	if (qs->index_page > 0) {
+		*have_prev = 1;
+		*prev = (struct gotweb_url){
+			.action = -1,
+			.index_page = qs->index_page - 1,
+			.page = -1,
+		};
+	}
+	if (t->next_disp == srv->max_repos_display &&
+	    t->repos_total != (qs->index_page + 1) *
+	    srv->max_repos_display) {
+		*have_next = 1;
+		*next = (struct gotweb_url){
+			.action = -1,
+			.index_page = qs->index_page + 1,
+			.page = -1,
+		};
 	}
 }
 
blob - bbd0dfbe71b15e16f66c7c842591a2ca49fd28ea
blob + 6ea1d90bca9cc05ffc240c807b165680feb3f72a
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
@@ -205,8 +205,7 @@ struct transport {
 	struct repo_dir		*repo_dir;
 	struct querystring	*qs;
 	char			*more_id;
-	char			*next_id;
-	char			*prev_id;
+	char			*tags_more_id;
 	unsigned int		 repos_total;
 	unsigned int		 next_disp;
 	unsigned int		 prev_disp;
@@ -469,7 +468,7 @@ void sockets_socket_accept(int, short, void *);
 int sockets_privinit(struct gotwebd *, struct socket *);
 
 /* gotweb.c */
-void gotweb_get_navs(struct request *, struct gotweb_url *, int *,
+void gotweb_index_navs(struct request *, struct gotweb_url *, int *,
     struct gotweb_url *, int *);
 int gotweb_render_age(struct template *, time_t);
 const struct got_error *gotweb_init_transport(struct transport **);
blob - 66fc2ec246ed0902a2966cc268ca02e2e4376dbe
blob + 163adf4f079d9ab05eb872f6ff25606766c646d7
--- gotwebd/pages.tmpl
+++ gotwebd/pages.tmpl
@@ -445,8 +445,11 @@ nextsep(char *s, char **t)
 		.headref = qs->headref,
 		.file = qs->file,
 	};
+
+	if (action == TAGS)
+		more.commit = t->tags_more_id;
 !}
-  {{ if t->more_id }}
+  {{ if more.commit }}
     <div id="np_wrapper">
       <div id="nav_more">
         <a href="{{ render gotweb_render_url(c, &more) }}">
@@ -460,11 +463,10 @@ nextsep(char *s, char **t)
 {{ define gotweb_render_navs(struct template *tp) }}
 {!
 	struct request		*c = tp->tp_arg;
-	struct transport	*t = c->t;
 	struct gotweb_url	 prev, next;
 	int			 have_prev, have_next;
 
-	gotweb_get_navs(c, &prev, &have_prev, &next, &have_next);
+	gotweb_index_navs(c, &prev, &have_prev, &next, &have_next);
 !}
 <div id="np_wrapper">
   <div id="nav_prev">
@@ -482,13 +484,6 @@ nextsep(char *s, char **t)
     {{ end }}
   </div>
 </div>
-{{ finally }}
-{!
-	free(t->next_id);
-	t->next_id = NULL;
-	free(t->prev_id);
-	t->prev_id = NULL;
-!}
 {{ end }}
 
 {{ define gotweb_render_commits(struct template *tp) }}
@@ -833,10 +828,7 @@ nextsep(char *s, char **t)
         {{ render tag_item(tp, rt) }}
       {{ end }}
     {{ end }}
-    {{ if t->next_id || t->prev_id }}
-      {! qs->action = TAGS; !}
-      {{ render gotweb_render_navs(tp) }}
-    {{ end }}
+    {{ render gotweb_render_more(tp, TAGS) }}
   {{ end }}
 </div>
 {{ end }}