author | Lars Hjemli <hjemli@gmail.com> | 2008-04-14 20:13:38 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-04-14 20:13:38 (UTC) |
commit | 5764fe95469f65fdee285467f0f87d188fc1a780 (patch) (unidiff) | |
tree | 0dc9e9545bd8b43fbf1a571f3ef239ff3aea771c /ui-log.c | |
parent | 35d19bbb641aa56a21fb2c238994716c272e154f (diff) | |
download | cgit-5764fe95469f65fdee285467f0f87d188fc1a780.zip cgit-5764fe95469f65fdee285467f0f87d188fc1a780.tar.gz cgit-5764fe95469f65fdee285467f0f87d188fc1a780.tar.bz2 |
Make branches, tags and log play better together in the summary view
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-log.c | 42 |
1 files changed, 26 insertions, 16 deletions
@@ -1,142 +1,152 @@ | |||
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 | #include "html.h" | 10 | #include "html.h" |
11 | #include "ui-shared.h" | 11 | #include "ui-shared.h" |
12 | 12 | ||
13 | int files, add_lines, rem_lines; | 13 | int files, add_lines, rem_lines; |
14 | 14 | ||
15 | void count_lines(char *line, int size) | 15 | void count_lines(char *line, int size) |
16 | { | 16 | { |
17 | if (size <= 0) | 17 | if (size <= 0) |
18 | return; | 18 | return; |
19 | 19 | ||
20 | if (line[0] == '+') | 20 | if (line[0] == '+') |
21 | add_lines++; | 21 | add_lines++; |
22 | 22 | ||
23 | else if (line[0] == '-') | 23 | else if (line[0] == '-') |
24 | rem_lines++; | 24 | rem_lines++; |
25 | } | 25 | } |
26 | 26 | ||
27 | void inspect_files(struct diff_filepair *pair) | 27 | void inspect_files(struct diff_filepair *pair) |
28 | { | 28 | { |
29 | files++; | 29 | files++; |
30 | if (ctx.repo->enable_log_linecount) | 30 | if (ctx.repo->enable_log_linecount) |
31 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); | 31 | cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines); |
32 | } | 32 | } |
33 | 33 | ||
34 | void print_commit(struct commit *commit) | 34 | void print_commit(struct commit *commit) |
35 | { | 35 | { |
36 | struct commitinfo *info; | 36 | struct commitinfo *info; |
37 | 37 | ||
38 | info = cgit_parse_commit(commit); | 38 | info = cgit_parse_commit(commit); |
39 | html("<tr><td>"); | 39 | html("<tr><td>"); |
40 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); | 40 | cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); |
41 | html("</td><td>"); | 41 | html("</td><td>"); |
42 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, | 42 | cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head, |
43 | sha1_to_hex(commit->object.sha1)); | 43 | sha1_to_hex(commit->object.sha1)); |
44 | html("</td><td>"); | ||
45 | html_txt(info->author); | ||
44 | if (ctx.repo->enable_log_filecount) { | 46 | if (ctx.repo->enable_log_filecount) { |
45 | files = 0; | 47 | files = 0; |
46 | add_lines = 0; | 48 | add_lines = 0; |
47 | rem_lines = 0; | 49 | rem_lines = 0; |
48 | cgit_diff_commit(commit, inspect_files); | 50 | cgit_diff_commit(commit, inspect_files); |
49 | html("</td><td class='right'>"); | 51 | html("</td><td>"); |
50 | htmlf("%d", files); | 52 | htmlf("%d", files); |
51 | if (ctx.repo->enable_log_linecount) { | 53 | if (ctx.repo->enable_log_linecount) { |
52 | html("</td><td class='right'>"); | 54 | html("</td><td>"); |
53 | htmlf("-%d/+%d", rem_lines, add_lines); | 55 | htmlf("-%d/+%d", rem_lines, add_lines); |
54 | } | 56 | } |
55 | } | 57 | } |
56 | html("</td><td>"); | ||
57 | html_txt(info->author); | ||
58 | html("</td></tr>\n"); | 58 | html("</td></tr>\n"); |
59 | cgit_free_commitinfo(info); | 59 | cgit_free_commitinfo(info); |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager) | 63 | void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, |
64 | char *path, int pager) | ||
64 | { | 65 | { |
65 | struct rev_info rev; | 66 | struct rev_info rev; |
66 | struct commit *commit; | 67 | struct commit *commit; |
67 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; | 68 | const char *argv[] = {NULL, tip, NULL, NULL, NULL}; |
68 | int argc = 2; | 69 | int argc = 2; |
69 | int i; | 70 | int i, columns = 3; |
70 | 71 | ||
71 | if (!tip) | 72 | if (!tip) |
72 | argv[1] = ctx.qry.head; | 73 | argv[1] = ctx.qry.head; |
73 | 74 | ||
74 | if (grep && pattern && (!strcmp(grep, "grep") || | 75 | if (grep && pattern && (!strcmp(grep, "grep") || |
75 | !strcmp(grep, "author") || | 76 | !strcmp(grep, "author") || |
76 | !strcmp(grep, "committer"))) | 77 | !strcmp(grep, "committer"))) |
77 | argv[argc++] = fmt("--%s=%s", grep, pattern); | 78 | argv[argc++] = fmt("--%s=%s", grep, pattern); |
78 | 79 | ||
79 | if (path) { | 80 | if (path) { |
80 | argv[argc++] = "--"; | 81 | argv[argc++] = "--"; |
81 | argv[argc++] = path; | 82 | argv[argc++] = path; |
82 | } | 83 | } |
83 | init_revisions(&rev, NULL); | 84 | init_revisions(&rev, NULL); |
84 | rev.abbrev = DEFAULT_ABBREV; | 85 | rev.abbrev = DEFAULT_ABBREV; |
85 | rev.commit_format = CMIT_FMT_DEFAULT; | 86 | rev.commit_format = CMIT_FMT_DEFAULT; |
86 | rev.verbose_header = 1; | 87 | rev.verbose_header = 1; |
87 | rev.show_root_diff = 0; | 88 | rev.show_root_diff = 0; |
88 | setup_revisions(argc, argv, &rev, NULL); | 89 | setup_revisions(argc, argv, &rev, NULL); |
89 | if (rev.grep_filter) { | 90 | if (rev.grep_filter) { |
90 | rev.grep_filter->regflags |= REG_ICASE; | 91 | rev.grep_filter->regflags |= REG_ICASE; |
91 | compile_grep_patterns(rev.grep_filter); | 92 | compile_grep_patterns(rev.grep_filter); |
92 | } | 93 | } |
93 | prepare_revision_walk(&rev); | 94 | prepare_revision_walk(&rev); |
94 | 95 | ||
95 | html("<table summary='log' class='list nowrap'>"); | 96 | if (pager) |
96 | html("<tr class='nohover'><th class='left'>Age</th>" | 97 | html("<table class='list nowrap'>"); |
97 | "<th class='left'>Message</th>"); | ||
98 | 98 | ||
99 | html("<tr class='nohover'><th class='left'>Age</th>" | ||
100 | "<th class='left'>Commit message</th>" | ||
101 | "<th class='left'>Author</th>"); | ||
99 | if (ctx.repo->enable_log_filecount) { | 102 | if (ctx.repo->enable_log_filecount) { |
100 | html("<th class='right'>Files</th>"); | 103 | html("<th class='left'>Files</th>"); |
101 | if (ctx.repo->enable_log_linecount) | 104 | columns++; |
102 | html("<th class='right'>Lines</th>"); | 105 | if (ctx.repo->enable_log_linecount) { |
106 | html("<th class='left'>Lines</th>"); | ||
107 | columns++; | ||
108 | } | ||
103 | } | 109 | } |
104 | html("<th class='left'>Author</th></tr>\n"); | 110 | html("</tr>\n"); |
105 | 111 | ||
106 | if (ofs<0) | 112 | if (ofs<0) |
107 | ofs = 0; | 113 | ofs = 0; |
108 | 114 | ||
109 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { | 115 | for (i = 0; i < ofs && (commit = get_revision(&rev)) != NULL; i++) { |
110 | free(commit->buffer); | 116 | free(commit->buffer); |
111 | commit->buffer = NULL; | 117 | commit->buffer = NULL; |
112 | free_commit_list(commit->parents); | 118 | free_commit_list(commit->parents); |
113 | commit->parents = NULL; | 119 | commit->parents = NULL; |
114 | } | 120 | } |
115 | 121 | ||
116 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { | 122 | for (i = 0; i < cnt && (commit = get_revision(&rev)) != NULL; i++) { |
117 | print_commit(commit); | 123 | print_commit(commit); |
118 | free(commit->buffer); | 124 | free(commit->buffer); |
119 | commit->buffer = NULL; | 125 | commit->buffer = NULL; |
120 | free_commit_list(commit->parents); | 126 | free_commit_list(commit->parents); |
121 | commit->parents = NULL; | 127 | commit->parents = NULL; |
122 | } | 128 | } |
123 | html("</table>\n"); | ||
124 | |||
125 | if (pager) { | 129 | if (pager) { |
126 | html("<div class='pager'>"); | 130 | htmlf("</table><div class='pager'>", |
131 | columns); | ||
127 | if (ofs > 0) { | 132 | if (ofs > 0) { |
128 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, | 133 | cgit_log_link("[prev]", NULL, NULL, ctx.qry.head, |
129 | ctx.qry.sha1, ctx.qry.path, | 134 | ctx.qry.sha1, ctx.qry.path, |
130 | ofs - cnt, ctx.qry.grep, | 135 | ofs - cnt, ctx.qry.grep, |
131 | ctx.qry.search); | 136 | ctx.qry.search); |
132 | html(" "); | 137 | html(" "); |
133 | } | 138 | } |
134 | if ((commit = get_revision(&rev)) != NULL) { | 139 | if ((commit = get_revision(&rev)) != NULL) { |
135 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, | 140 | cgit_log_link("[next]", NULL, NULL, ctx.qry.head, |
136 | ctx.qry.sha1, ctx.qry.path, | 141 | ctx.qry.sha1, ctx.qry.path, |
137 | ofs + cnt, ctx.qry.grep, | 142 | ofs + cnt, ctx.qry.grep, |
138 | ctx.qry.search); | 143 | ctx.qry.search); |
139 | } | 144 | } |
140 | html("</div>"); | 145 | html("</div>"); |
146 | } else if ((commit = get_revision(&rev)) != NULL) { | ||
147 | html("<tr class='nohover'><td colspan='3'>"); | ||
148 | cgit_log_link("[...]", NULL, NULL, ctx.qry.head, NULL, NULL, 0, | ||
149 | NULL, NULL); | ||
150 | html("</td></tr>\n"); | ||
141 | } | 151 | } |
142 | } | 152 | } |