aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
authorGravatar Lars Hjemli <hjemli@gmail.com>2006-12-12 01:04:19 (JST)
committerGravatar Lars Hjemli <hjemli@gmail.com>2006-12-12 01:04:19 (JST)
commitd14c5f6d3ac827e7b46831c4151638ab4b638ae1 (patch)
treed6592747d098d2fb2ca7a0e653984256ac9ac1a5 /cgit.c
parent1418034e642fee67c981b31e4c3eb6e8ae14e303 (diff)
downloadcgit-d14c5f6d3ac827e7b46831c4151638ab4b638ae1.zip
cgit-d14c5f6d3ac827e7b46831c4151638ab4b638ae1.tar.gz
Move log-functions into ui-log.c
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c107
1 files changed, 1 insertions, 106 deletions
diff --git a/cgit.c b/cgit.c
index 300fe46..30a9a2a 100644
--- a/cgit.c
+++ b/cgit.c
@@ -84,111 +84,6 @@ void cgit_querystring_cb(const char *name, const char *value)
84 } 84 }
85} 85}
86 86
87static int get_one_line(char *txt)
88{
89 char *t;
90
91 for(t=txt; *t != '\n' && t != '\0'; t++)
92 ;
93 *t = '\0';
94 return t-txt-1;
95}
96
97static void cgit_print_commit_shortlog(struct commit *commit)
98{
99 char *h, *t, *p;
100 char *tree = NULL, *author = NULL, *subject = NULL;
101 int len;
102 time_t sec;
103 struct tm *time;
104 char buf[32];
105
106 h = t = commit->buffer;
107
108 if (strncmp(h, "tree ", 5))
109 die("Bad commit format: %s",
110 sha1_to_hex(commit->object.sha1));
111
112 len = get_one_line(h);
113 tree = h+5;
114 h += len + 2;
115
116 while (!strncmp(h, "parent ", 7))
117 h += get_one_line(h) + 2;
118
119 if (!strncmp(h, "author ", 7)) {
120 author = h+7;
121 h += get_one_line(h) + 2;
122 t = author;
123 while(t!=h && *t!='<')
124 t++;
125 *t='\0';
126 p = t;
127 while(--t!=author && *t==' ')
128 *t='\0';
129 while(++p!=h && *p!='>')
130 ;
131 while(++p!=h && !isdigit(*p))
132 ;
133
134 t = p;
135 while(++p && isdigit(*p))
136 ;
137 *p = '\0';
138 sec = atoi(t);
139 time = gmtime(&sec);
140 }
141
142 while((len = get_one_line(h)) > 0)
143 h += len+2;
144
145 h++;
146 len = get_one_line(h);
147
148 subject = h;
149
150 html("<tr><td>");
151 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time);
152 html_txt(buf);
153 html("</td><td>");
154 char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1));
155 char *url = cgit_pageurl(cgit_query_repo, "view", qry);
156 html_link_open(url, NULL, NULL);
157 html_txt(subject);
158 html_link_close();
159 html("</td><td>");
160 html_txt(author);
161 html("</td></tr>\n");
162}
163
164static void cgit_print_log(const char *tip, int ofs, int cnt)
165{
166 struct rev_info rev;
167 struct commit *commit;
168 const char *argv[2] = {NULL, tip};
169 int n = 0;
170
171 init_revisions(&rev, NULL);
172 rev.abbrev = DEFAULT_ABBREV;
173 rev.commit_format = CMIT_FMT_DEFAULT;
174 rev.verbose_header = 1;
175 rev.show_root_diff = 0;
176 setup_revisions(2, argv, &rev, NULL);
177 prepare_revision_walk(&rev);
178
179 html("<h2>Log</h2>");
180 html("<table class='list'>");
181 html("<tr><th>Date</th><th>Message</th><th>Author</th></tr>\n");
182 while ((commit = get_revision(&rev)) != NULL && n++ < 100) {
183 cgit_print_commit_shortlog(commit);
184 free(commit->buffer);
185 commit->buffer = NULL;
186 free_commit_list(commit->parents);
187 commit->parents = NULL;
188 }
189 html("</table>\n");
190}
191
192static void cgit_print_object(char *hex) 87static void cgit_print_object(char *hex)
193{ 88{
194 unsigned char sha1[20]; 89 unsigned char sha1[20];
@@ -238,7 +133,7 @@ static void cgit_print_repo_page(struct cacheitem *item)
238 cgit_print_docstart(title, item); 133 cgit_print_docstart(title, item);
239 cgit_print_pageheader(title); 134 cgit_print_pageheader(title);
240 if (!cgit_query_page) 135 if (!cgit_query_page)
241 cgit_print_repo_summary(); 136 cgit_print_summary();
242 else if (!strcmp(cgit_query_page, "log")) { 137 else if (!strcmp(cgit_query_page, "log")) {
243 cgit_print_log(cgit_query_head, 0, 100); 138 cgit_print_log(cgit_query_head, 0, 100);
244 } else if (!strcmp(cgit_query_page, "view")) { 139 } else if (!strcmp(cgit_query_page, "view")) {