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.
25 #define SHA1_HEADER <openssl/sha.h>
26 #include "git/cache.h"
27 #include "git/commit.h"
29 #include "git/revision.h"
32 webgit_log_link (struct webgit_query* query,
35 const char* object, int object_len,
41 html_attr ("href", html(
42 html_fmt ("%s?repo=%s&action=log&head=%s",
43 query->request->script_name,
46 object ? html_fmt("&object=%.*s",
49 count > 0 ? html_fmt("&count=%d",
61 webgit_log_menu_action (struct webgit_query* query)
64 return html ("TODO: log sidebar");
69 webgit_log_table (struct webgit_query* query, const char* object, int count, int msg_flag)
72 const char* argv[] = {NULL, object, NULL};
75 init_revisions (&rev, NULL);
76 rev.verbose_header = 1;
79 setup_revisions (argc, argv, &rev, NULL);
81 prepare_revision_walk(&rev);
83 Html table = html_list ();
84 Html cont = html_list ();
86 struct commit *commit;
87 while ((commit = get_revision (&rev)))
91 /* displayed query->count lines, finish */
92 html_list_append (cont,
97 sha1_to_hex(commit->object.sha1), 40,
101 free(commit->buffer);
102 commit->buffer = NULL;
103 free_commit_list(commit->parents);
104 commit->parents = NULL;
108 /* TODO: check if commit is one of the heads and display that */
111 webgit_object_commit_committer_date_parse (commit, &tm);
113 char pretty_date[256];
114 strftime (pretty_date, 255, "%c", &tm);
116 html_list_append (table,
120 html(html_tag ("td"),
121 html_strndup (pretty_date, 254)
123 html(html_tag ("td"),
124 webgit_object_link (query,
126 strlen (query->repo),
127 sha1_to_hex (commit->object.sha1),
131 webgit_object_commit_header_parse (commit)
137 html(html_tag ("td"),
139 webgit_object_commit_author_name_parse (commit),
140 webgit_object_commit_author_email_parse (commit)
143 html (html_tag ("td"),
147 webgit_object_link (query,
149 strlen (query->repo),
150 webgit_object_commit_tree_parse (commit),
163 html_list_append (table,
166 html(html_tag ("td", html_attr ("colspan", "2")),
167 html(html_tag ("pre"),
168 webgit_object_commit_message_parse (commit)
170 html (html_tag ("hr"))
176 #if 0 /* traverse parents */
177 struct commit *parent;
178 while ((parent = pop_commit (&commit->parents)))
183 free(commit->buffer);
184 commit->buffer = NULL;
185 free_commit_list(commit->parents);
186 commit->parents = NULL;
189 return html (html ( html_tag ("table", html_attr ("id", "log")), table), cont);
194 webgit_log_content_action (struct webgit_query* query)
198 object = query->object;
199 else if (query->head)
200 object = query->head;
204 return webgit_log_table (query, object, query->count, 1);