]>
git.cameronkatri.com Git - cgit.git/blob - ui-log.c
1 /* ui-log.c: functions for log output
3 * Copyright (C) 2006 Lars Hjemli
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
11 #include "ui-shared.h"
13 int files
, add_lines
, rem_lines
;
15 void count_lines(char *line
, int size
)
23 else if (line
[0] == '-')
27 void inspect_files(struct diff_filepair
*pair
)
30 if (ctx
.repo
->enable_log_linecount
)
31 cgit_diff_files(pair
->one
->sha1
, pair
->two
->sha1
, count_lines
);
34 void print_commit(struct commit
*commit
)
36 struct commitinfo
*info
;
38 info
= cgit_parse_commit(commit
);
40 cgit_print_age(commit
->date
, TM_WEEK
* 2, FMT_SHORTDATE
);
42 cgit_commit_link(info
->subject
, NULL
, NULL
, ctx
.qry
.head
,
43 sha1_to_hex(commit
->object
.sha1
));
44 if (ctx
.repo
->enable_log_filecount
) {
48 cgit_diff_commit(commit
, inspect_files
);
49 html("</td><td class='right'>");
51 if (ctx
.repo
->enable_log_linecount
) {
52 html("</td><td class='right'>");
53 htmlf("-%d/+%d", rem_lines
, add_lines
);
57 html_txt(info
->author
);
59 cgit_free_commitinfo(info
);
63 void cgit_print_log(const char *tip
, int ofs
, int cnt
, char *grep
, char *pattern
, char *path
, int pager
)
66 struct commit
*commit
;
67 const char *argv
[] = {NULL
, tip
, NULL
, NULL
, NULL
};
72 argv
[1] = ctx
.qry
.head
;
74 if (grep
&& pattern
&& (!strcmp(grep
, "grep") ||
75 !strcmp(grep
, "author") ||
76 !strcmp(grep
, "committer")))
77 argv
[argc
++] = fmt("--%s=%s", grep
, pattern
);
83 init_revisions(&rev
, NULL
);
84 rev
.abbrev
= DEFAULT_ABBREV
;
85 rev
.commit_format
= CMIT_FMT_DEFAULT
;
86 rev
.verbose_header
= 1;
87 rev
.show_root_diff
= 0;
88 setup_revisions(argc
, argv
, &rev
, NULL
);
89 if (rev
.grep_filter
) {
90 rev
.grep_filter
->regflags
|= REG_ICASE
;
91 compile_grep_patterns(rev
.grep_filter
);
93 prepare_revision_walk(&rev
);
95 html("<table summary='log' class='list nowrap'>");
96 html("<tr class='nohover'><th class='left'>Age</th>"
97 "<th class='left'>Message</th>");
99 if (ctx
.repo
->enable_log_filecount
) {
100 html("<th class='right'>Files</th>");
101 if (ctx
.repo
->enable_log_linecount
)
102 html("<th class='right'>Lines</th>");
104 html("<th class='left'>Author</th></tr>\n");
109 for (i
= 0; i
< ofs
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
110 free(commit
->buffer
);
111 commit
->buffer
= NULL
;
112 free_commit_list(commit
->parents
);
113 commit
->parents
= NULL
;
116 for (i
= 0; i
< cnt
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
117 print_commit(commit
);
118 free(commit
->buffer
);
119 commit
->buffer
= NULL
;
120 free_commit_list(commit
->parents
);
121 commit
->parents
= NULL
;
126 html("<div class='pager'>");
128 cgit_log_link("[prev]", NULL
, NULL
, ctx
.qry
.head
,
129 ctx
.qry
.sha1
, ctx
.qry
.path
,
130 ofs
- cnt
, ctx
.qry
.grep
,
134 if ((commit
= get_revision(&rev
)) != NULL
) {
135 cgit_log_link("[next]", NULL
, NULL
, ctx
.qry
.head
,
136 ctx
.qry
.sha1
, ctx
.qry
.path
,
137 ofs
+ cnt
, ctx
.qry
.grep
,