commit - 8957da7c28eda864d43699ccb657c9b48278d7c4
commit + 723721e290eec4393f8cad56a6bb38ca9fd379c7
blob - 811b305e2a8b1fc494ec5bb3fde95f5c9da249d7
blob + 09c4ddba2490572fbc8bbc7dd65fcc63ca5eb5bf
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
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);
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;
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;
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);
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)
* 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);
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;
}
}
if (new_repo_tag->tag_commit == NULL) {
error = got_error_from_errno("strdup");
free(tag_commit0);
- goto err;
+ goto done;
}
free(tag_commit0);
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;
}
}
}
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 - eb61b43d2ee522780085b404bdef3baabfb6d050
blob + 97575de5d359b4f44fded11be7f741148707b690
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
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) {
}
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;
*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 - 108a7b3500fd706e64a0b9a2fa6519196ebe51ca
blob + e3fd4407e26812d1c9cfc32955e1a5d603f4a1a9
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
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;
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 - 99a7c70488d6b2491287f77419bd029e71eaf201
blob + b1a49ca97e7c22bd8397d11f483959d0458f3ae4
--- gotwebd/pages.tmpl
+++ gotwebd/pages.tmpl
.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) }}">
{{ 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">
{{ 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) }}
{{ 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 }}