author | Lars Hjemli <hjemli@gmail.com> | 2006-12-16 13:58:20 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2006-12-16 13:58:20 (UTC) |
commit | aaa24bdd30303128bded8487cd9f63b54c3b8dcd (patch) (unidiff) | |
tree | 0fd8b32643c205d819f98a827eca3e78fad21bfa /ui-log.c | |
parent | fa82b03e05366e3c6ca1b74c8c83d6e00e0ef1e6 (diff) | |
download | cgit-aaa24bdd30303128bded8487cd9f63b54c3b8dcd.zip cgit-aaa24bdd30303128bded8487cd9f63b54c3b8dcd.tar.gz cgit-aaa24bdd30303128bded8487cd9f63b54c3b8dcd.tar.bz2 |
Add cgit_free_commitinfo() and use where needed
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-log.c | 5 |
1 files changed, 1 insertions, 4 deletions
@@ -1,92 +1,89 @@ | |||
1 | /* ui-log.c: functions for log output | 1 | /* ui-log.c: functions for log output |
2 | * | 2 | * |
3 | * Copyright (C) 2006 Lars Hjemli | 3 | * Copyright (C) 2006 Lars Hjemli |
4 | * | 4 | * |
5 | * Licensed under GNU General Public License v2 | 5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) | 6 | * (see COPYING for full license text) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "cgit.h" | 9 | #include "cgit.h" |
10 | 10 | ||
11 | void print_commit(struct commit *commit) | 11 | void print_commit(struct commit *commit) |
12 | { | 12 | { |
13 | char buf[32]; | 13 | char buf[32]; |
14 | struct commitinfo *info; | 14 | struct commitinfo *info; |
15 | struct tm *time; | 15 | struct tm *time; |
16 | 16 | ||
17 | info = cgit_parse_commit(commit); | 17 | info = cgit_parse_commit(commit); |
18 | time = gmtime(&commit->date); | 18 | time = gmtime(&commit->date); |
19 | html("<tr><td>"); | 19 | html("<tr><td>"); |
20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); | 20 | strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", time); |
21 | html_txt(buf); | 21 | html_txt(buf); |
22 | html("</td><td>"); | 22 | html("</td><td>"); |
23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); | 23 | char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1)); |
24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); | 24 | char *url = cgit_pageurl(cgit_query_repo, "commit", qry); |
25 | html_link_open(url, NULL, NULL); | 25 | html_link_open(url, NULL, NULL); |
26 | html_txt(info->subject); | 26 | html_txt(info->subject); |
27 | html_link_close(); | 27 | html_link_close(); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | html_txt(info->author); | 29 | html_txt(info->author); |
30 | html("</td></tr>\n"); | 30 | html("</td></tr>\n"); |
31 | free(info->author); | 31 | cgit_free_commitinfo(info); |
32 | free(info->committer); | ||
33 | free(info->subject); | ||
34 | free(info); | ||
35 | } | 32 | } |
36 | 33 | ||
37 | 34 | ||
38 | void cgit_print_log(const char *tip, int ofs, int cnt) | 35 | void cgit_print_log(const char *tip, int ofs, int cnt) |
39 | { | 36 | { |
40 | struct rev_info rev; | 37 | struct rev_info rev; |
41 | struct commit *commit; | 38 | struct commit *commit; |
42 | const char *argv[2] = {NULL, tip}; | 39 | const char *argv[2] = {NULL, tip}; |
43 | int i; | 40 | int i; |
44 | 41 | ||
45 | init_revisions(&rev, NULL); | 42 | init_revisions(&rev, NULL); |
46 | rev.abbrev = DEFAULT_ABBREV; | 43 | rev.abbrev = DEFAULT_ABBREV; |
47 | rev.commit_format = CMIT_FMT_DEFAULT; | 44 | rev.commit_format = CMIT_FMT_DEFAULT; |
48 | rev.verbose_header = 1; | 45 | rev.verbose_header = 1; |
49 | rev.show_root_diff = 0; | 46 | rev.show_root_diff = 0; |
50 | setup_revisions(2, argv, &rev, NULL); | 47 | setup_revisions(2, argv, &rev, NULL); |
51 | prepare_revision_walk(&rev); | 48 | prepare_revision_walk(&rev); |
52 | 49 | ||
53 | html("<h2>Log</h2>"); | 50 | html("<h2>Log</h2>"); |
54 | html("<table class='list log'>"); | 51 | html("<table class='list log'>"); |
55 | html("<tr><th class='left'>Date</th><th class='left'>Message</th><th class='left'>Author</th></tr>\n"); | 52 | html("<tr><th class='left'>Date</th><th class='left'>Message</th><th class='left'>Author</th></tr>\n"); |
56 | 53 | ||
57 | if (ofs<0) | 54 | if (ofs<0) |
58 | ofs = 0; | 55 | ofs = 0; |
59 | 56 | ||
60 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 57 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
61 | free(commit->buffer); | 58 | free(commit->buffer); |
62 | commit->buffer = NULL; | 59 | commit->buffer = NULL; |
63 | free_commit_list(commit->parents); | 60 | free_commit_list(commit->parents); |
64 | commit->parents = NULL; | 61 | commit->parents = NULL; |
65 | } | 62 | } |
66 | 63 | ||
67 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | 64 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
68 | print_commit(commit); | 65 | print_commit(commit); |
69 | free(commit->buffer); | 66 | free(commit->buffer); |
70 | commit->buffer = NULL; | 67 | commit->buffer = NULL; |
71 | free_commit_list(commit->parents); | 68 | free_commit_list(commit->parents); |
72 | commit->parents = NULL; | 69 | commit->parents = NULL; |
73 | } | 70 | } |
74 | html("</table>\n"); | 71 | html("</table>\n"); |
75 | 72 | ||
76 | html("<div class='pager'>"); | 73 | html("<div class='pager'>"); |
77 | if (ofs > 0) { | 74 | if (ofs > 0) { |
78 | html(" <a href='"); | 75 | html(" <a href='"); |
79 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, | 76 | html(cgit_pageurl(cgit_query_repo, cgit_query_page, |
80 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); | 77 | fmt("h=%s&ofs=%d", tip, ofs-cnt))); |
81 | html("'>[prev]</a> "); | 78 | html("'>[prev]</a> "); |
82 | } | 79 | } |
83 | 80 | ||
84 | if ((commit = get_revision(&rev)) != NULL) { | 81 | if ((commit = get_revision(&rev)) != NULL) { |
85 | html(" <a href='"); | 82 | html(" <a href='"); |
86 | html(cgit_pageurl(cgit_query_repo, "log", | 83 | html(cgit_pageurl(cgit_query_repo, "log", |
87 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); | 84 | fmt("h=%s&ofs=%d", tip, ofs+cnt))); |
88 | html("'>[next]</a> "); | 85 | html("'>[next]</a> "); |
89 | } | 86 | } |
90 | html("</div>"); | 87 | html("</div>"); |
91 | } | 88 | } |
92 | 89 | ||