]>
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 int files
, add_lines
, rem_lines
;
13 void count_lines(char *line
, int size
)
21 else if (line
[0] == '-')
25 void inspect_files(struct diff_filepair
*pair
)
28 if (cgit_repo
->enable_log_linecount
)
29 cgit_diff_files(pair
->one
->sha1
, pair
->two
->sha1
, count_lines
);
32 void print_commit(struct commit
*commit
)
34 struct commitinfo
*info
;
36 info
= cgit_parse_commit(commit
);
38 cgit_print_age(commit
->date
, TM_WEEK
* 2, FMT_SHORTDATE
);
40 cgit_commit_link(info
->subject
, NULL
, NULL
, cgit_query_head
,
41 sha1_to_hex(commit
->object
.sha1
));
42 if (cgit_repo
->enable_log_filecount
) {
46 cgit_diff_commit(commit
, inspect_files
);
47 html("</td><td class='right'>");
49 if (cgit_repo
->enable_log_linecount
) {
50 html("</td><td class='right'>");
51 htmlf("-%d/+%d", rem_lines
, add_lines
);
55 html_txt(info
->author
);
57 cgit_free_commitinfo(info
);
61 void cgit_print_log(const char *tip
, int ofs
, int cnt
, char *grep
, char *pattern
, char *path
, int pager
)
64 struct commit
*commit
;
65 const char *argv
[] = {NULL
, tip
, NULL
, NULL
, NULL
};
70 argv
[1] = cgit_query_head
;
72 if (grep
&& pattern
&& (!strcmp(grep
, "grep") ||
73 !strcmp(grep
, "author") ||
74 !strcmp(grep
, "committer")))
75 argv
[argc
++] = fmt("--%s=%s", grep
, pattern
);
81 init_revisions(&rev
, NULL
);
82 rev
.abbrev
= DEFAULT_ABBREV
;
83 rev
.commit_format
= CMIT_FMT_DEFAULT
;
84 rev
.verbose_header
= 1;
85 rev
.show_root_diff
= 0;
86 setup_revisions(argc
, argv
, &rev
, NULL
);
87 if (rev
.grep_filter
) {
88 rev
.grep_filter
->regflags
|= REG_ICASE
;
89 compile_grep_patterns(rev
.grep_filter
);
91 prepare_revision_walk(&rev
);
93 html("<table summary='log' class='list nowrap'>");
94 html("<tr class='nohover'><th class='left'>Age</th>"
95 "<th class='left'>Message</th>");
97 if (cgit_repo
->enable_log_filecount
) {
98 html("<th class='right'>Files</th>");
99 if (cgit_repo
->enable_log_linecount
)
100 html("<th class='right'>Lines</th>");
102 html("<th class='left'>Author</th></tr>\n");
107 for (i
= 0; i
< ofs
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
108 free(commit
->buffer
);
109 commit
->buffer
= NULL
;
110 free_commit_list(commit
->parents
);
111 commit
->parents
= NULL
;
114 for (i
= 0; i
< cnt
&& (commit
= get_revision(&rev
)) != NULL
; i
++) {
115 print_commit(commit
);
116 free(commit
->buffer
);
117 commit
->buffer
= NULL
;
118 free_commit_list(commit
->parents
);
119 commit
->parents
= NULL
;
124 html("<div class='pager'>");
126 cgit_log_link("[prev]", NULL
, NULL
, cgit_query_head
,
127 cgit_query_sha1
, cgit_query_path
,
128 ofs
- cnt
, cgit_query_grep
,
132 if ((commit
= get_revision(&rev
)) != NULL
) {
133 cgit_log_link("[next]", NULL
, NULL
, cgit_query_head
,
134 cgit_query_sha1
, cgit_query_path
,
135 ofs
+ cnt
, cgit_query_grep
,