2 cehtehs git web frontend
5 2007, 2008, Christian Thaeter <ct@pipapo.org>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #define SHA1_HEADER <openssl/sha.h>
30 #include "git/cache.h"
31 #include "git/commit.h"
36 struct webgit_repo_info* repo;
44 webgit_branch_link (struct webgit_repo_info* repo, const char* branch, int count, Html text)
48 html_attr ("href", html(
49 html_fmt ("%s?repo=%s&action=branch",
50 repo->query->request->script_name,
52 branch ? html_fmt("&ref=%s", branch) : html (),
53 count > 0 ? html_fmt("&count=%d",
64 show_branch_ref (const char *refname, const unsigned char *sha1, int flags, void *data)
68 struct branch_context* ctx = (struct branch_context*) data;
69 struct webgit_repo_info* repo = ctx->repo;
73 if (!strcmp (ctx->start, refname))
81 /* displayed query->count lines, finish */
82 html_list_append (ctx->cont,
91 struct commit* commit = lookup_commit_reference (sha1);
94 webgit_object_commit_committer_date_parse (commit, NULL);
96 html_list_append (ctx->table,
101 webgit_log_link (repo->query,
106 html ((char*)refname)
111 webgit_object_link (repo->query,
112 repo->name, strlen(repo->name),
113 sha1_to_hex (sha1), 40,
116 webgit_pretty_age (repo->query->now - date))
121 webgit_object_commit_committer_name_parse (commit),
122 webgit_object_commit_committer_email_parse (commit)
127 webgit_object_link (repo->query,
128 repo->name, strlen(repo->name),
129 webgit_object_commit_tree_parse (commit), 40,
139 free(commit->buffer);
140 commit->buffer = NULL;
141 free_commit_list(commit->parents);
142 commit->parents = NULL;
149 webgit_branch_table (struct webgit_repo_info* repo, const char* head, int count)
151 struct branch_context ctx;
153 ctx.table = html_list ();
154 ctx.cont = html_list ();
158 for_each_branch_ref (show_branch_ref, &ctx);
160 return html (html ( html_tag ("table"), ctx.table), ctx.cont);